- 1. Rounded Corners
- Invalid rounding for parent layer only
- ImgView.layer.cornerRadius = 100;
- This property allows all sublayers of the Uiimageview to change with the parent layer
- ImgView.layer.masksToBounds = YES;
- 2. Shadows
- ImgView.layer.shadowColor = [Uicolor Bluecolor]. Cgcolor;
- ImgView.layer.shadowOffset = Cgsizemake (10, 10);
- imgView.layer.shadowOpacity = 0.8;
10.//3. Setting transform, deformation
- (1) Panning
- ImgView.layer.transform = catransform3dmaketranslation (0,-100, 0);
- (2) Rotation
- The axis of rotation along which the value is 1
- ImgView.layer.transform = catransform3dmakerotation (m_pi, 0, 0, 1);
- (3) Zoom
- ImgView.layer.transform = Catransform3dmakescale (0.5, 1, 1);
Search for Transform3D in 18.//documents to get KeyPath
- Move Up 100
- [Imgview.layer setvalue:@-100 forkeypath:@ "TRANSFORM.TRANSLATION.Y"];
- Rotate counterclockwise 45 degrees along the z axis
- [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.
- [Self.view.layer Addsublayer:mylayer];
28.//2. Setting the display properties of a layer
- Dimensions and Colors
- Mylayer.bounds = CGRectMake (0, 0, 200, 200);
- Mylayer.backgroundcolor = [Uicolor Redcolor]. Cgcolor;
- Display location, default is the center point, and the location is determined by the anchor point.
- Mylayer.position = cgpointmake (100, 100);
34.//anchor point, default value is 0.5,0.5
- 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