Basic use of Calayer

Source: Internet
Author: User

    1. 1. Rounded Corners
    2. Invalid rounding for parent layer only
    3. ImgView.layer.cornerRadius = 100;
    4. This property allows all sublayers of the Uiimageview to change with the parent layer
    5. ImgView.layer.masksToBounds = YES;
    6. 2. Shadows
    7. ImgView.layer.shadowColor = [Uicolor Bluecolor]. Cgcolor;
    8. ImgView.layer.shadowOffset = Cgsizemake (10, 10);
    9. imgView.layer.shadowOpacity = 0.8;

10.//3. Setting transform, deformation

    1. (1) Panning
    2. ImgView.layer.transform = catransform3dmaketranslation (0,-100, 0);
    3. (2) Rotation
    4. The axis of rotation along which the value is 1
    5. ImgView.layer.transform = catransform3dmakerotation (m_pi, 0, 0, 1);
    6. (3) Zoom
    7. ImgView.layer.transform = Catransform3dmakescale (0.5, 1, 1);

Search for Transform3D in 18.//documents to get KeyPath

    1. Move Up 100
    2. [Imgview.layer setvalue:@-100 forkeypath:@ "TRANSFORM.TRANSLATION.Y"];
    3. Rotate counterclockwise 45 degrees along the z axis
    4. [Imgview.layer setvalue:@-m_pi_4 forkeypath:@ "Transform.rotation.z"];

25. Custom Calayer

26.//1. You must add a custom layer to the parent layer to display.

    1. [Self.view.layer Addsublayer:mylayer];

28.//2. Setting the display properties of a layer

    1. Dimensions and Colors
    2. Mylayer.bounds = CGRectMake (0, 0, 200, 200);
    3. Mylayer.backgroundcolor = [Uicolor Redcolor]. Cgcolor;
    4. Display location, default is the center point, and the location is determined by the anchor point.
    5. Mylayer.position = cgpointmake (100, 100);

34.//anchor point, default value is 0.5,0.5

    1. Mylayer.anchorpoint = Cgpointmake (0.5, 0.5);

The values of 36.//position and anchorpoint determine where the layer is displayed.

37.//layer zooms in and out with the anchor point as the center point when zoomed in and zoomed out.

38.UIImage *image = [UIImage imagenamed:@ "2012100413195471481.jpg"];

39.mylayer.contents = (ID) image. Cgimage;

41.//fades the animation, changing the layer's transparency, ranging from 0 to 1. Mylayer.opacity

43.//self.view.layer is a rootlayer, no implicit animation effect. All non-rootlayer have an implicit animation effect.

Basic use of Calayer

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.