1. The view's display is based on a layer, which also controls the display, gets the layer of the current view, and adds rounded borders to it.
// set the width of the layer border to 2 View.layer.borderwidth=2; // If you need to add a color to a layer you need to convert to Cgcolor object view.layer.bordercolor=[Uicolor Greencolor]. Cgcolor; // set the fillet radius of the border to ten view.layer.cornerradius=;
2. Set the shadow of the view through the layer
// 1 Setting the current shadow color view.layer.shadowcolor=[Uicolor Blackcolor]. Cgcolor; // 2 Set the current convex shadow, this method to control the extent of the current shadow convex, so as to achieve the desired effect View.layer.shadowoffset=cgsizemake (55); // 3 Set the current transparency view.layer.shadowopacity=0.5;
3. Custom Layer
Calayer *layer=[Calayer layer]; Layer.bordercolor=[Uicolor Redcolor]. Cgcolor; Layer.borderwidth=2; Layer.cornerradius=Ten; Layer.backgroundcolor=[Uicolor Redcolor]. Cgcolor;layer.bounds=cgrectmake (0,0, $, -); //set position control current positionLayer.position=cgpointmake ( -, -);//setting the anchor point to control the position of the position, the size of the anchor point range is 0-1, it can be understood to be proportional to the position of the layer to locate the point, the point to the position property refers to the position, so that two properties can be very good control of the current layer positionLayer.anchorpoint=cgpointmake (0,0);//adds the current layer to the currently displayed layer[Self.view.layer Addsublayer:layer];
4. Layer 3D affine transform
1. Panning
1.1, 3D translation is divided into x Y Z three-dimensional, set the value will be set in the direction of translation
T1:x axis offset position, down to positive.
T2:y axis offset position, positive to right.
T3:z the axis offset position, and a positive number outward.
Nsvalue * nav=[nsvalue valuewithcatransform3d:catransform3dmaketranslation (T1, T2, T3)];[ View.layer setvalue:nav forkey:@ "transform"];
1.2, through the KVC assignment, as shown in the table below
// 100 ) Forkeypath:@ " transform.translation.x " ]; // [View.layersetvalue:@ (100 ) Forkeypath:@ " Span style= "COLOR: #800000" >transform.translation.y " ]; // in z direction [View.layersetvalue:@ (100 ) Forkeypath:@ " Span style= "COLOR: #800000" >transform.translation.z "];
2. Rotation
2.1, rotation has four parameters, the first is the angle of rotation, in radians, the following three values correspond to three axes, you can set rotation around different axes
X: Rotates along the x-axis, with a value range between 1 and 1
Y: Rotates along the y-axis, with a value range between 1 and 1
Z: Rotates along the z-axis, with a value range between 1 and 1
[UIView animatewithduration:1 animations:^{ view.layer.transform00 ,-1); }];
2.2, through the KVC assignment value
// rotate along the z axis [View.layer setvalue:@ (m_pi_2) Forkeypath:@ "transform.rotation.z"]; // rotate along the x axis [View.layer setvalue:@ (m_pi_2) Forkeypath:@ "transform.rotation.x"];
3. Zoom
3.1, three parameters are scaled along each axis in multiples, sequentially X Y z three-dimensional.
View.layer.transform=catransform3dmakescale (11.51);
3.2, through the KVC assignment value
// 1.5 times-fold magnification along the x-axis [View.layer setvalue:@ (1.5) Forkeypath:@ "transform.scale.x"]; // 1.5 times-fold magnification along the y-axis [View.layer setvalue:@ (1.5) Forkeypath:@ "transform.scale.y"]; // 1.5 times x magnification along the z axis [View.layer setvalue:@ (1.5) Forkeypath:@ "transform.scale.z"];
Layer and 3D affine transformations