Layer
Each control has its own layer, and everything in this space is displayed on top of the layer, and the control itself has no function of displaying things, only having a layer to show things
Getting a layer
CALayer *layer = self.testView.layer;
Example of using a UIView layer
UIView itself has only one layer, the primary layer
Self. TestView. Layer. BorderWidth=Ten;//Set Border sizeSelf. TestView. Layer. BorderColor= [Uicolor Bluecolor]. Cgcolor;//Set Border colorSelf. TestView. Layer. Cornerradius=Ten;//Set the fillet of the viewSelf. TestView. Layer. Shadowoffset= Cgsizemake (Ten,Ten);//Set shadow, default Black transparent, followed by shadow deviation (which direction the shadow will be biased) the bottom right corner full positiveSelf. TestView. Layer. Shadowcolor= [Uicolor Blackcolor]. Cgcolor;//Set color for ShadowsSelf. TestView. Layer. Shadowopacity=0.5;//Set TransparencySelf. TestView. Layer. Maskstobounds= YES;//settings beyond the main layer will be cut off, the shadow is not displayed is also the reason
Uiimageview For example round angle implementation
The Uiimageview control has more than one layer, and the picture is not displayed in the main layer, so changing the corner of the main layer is a prototype and cannot change the corners of the picture display layer
Self. ImageView. Layer. BorderWidth=Ten;//Set Border width sizeSelf. ImageView. Layer. BorderColor= [Uicolor Bluecolor]. Cgcolor;//Set Border colorSet the layer fillet, because the Uiimageview has two layers, the picture is displayed on the complex layer,//So only set this property does not turn round//To set the Maskstobounds property to Yesself. ImageView. Layer. Cornerradius=Ten;Self. ImageView. Layer. Maskstobounds= YES;//content that goes beyond the main layer will be lost .
About layer rotation, panning, zooming
Layer can only be rotated, panned, scaled using 3D
Self. ImageView. Layer. Transform= Catransform3dmakerotation (M_pi_4,1,0.5,0)//layer layer of rotation, using 3DControl scaling using Kvcnsvalue *value = [Nsvalue valuewithcatransform3d:catransform3dmakerotation (M_pi_4,0,0,1)];[Self. ImageView. LayerSetvalue:value forkeypath:@"Transform"];Equal to the above two sentences using kvc[self. ImageView. Layersetvalue:@ (m_pi_2) forkeypath:@"Transform.rotation"];The control itself scales and rotates self. ImageView. Transform= Cgaffinetransformmakerotation (M_pi_4);Self. ImageView. Transform= Cgaffinetransformmakescale (1.5,1.5);
Getting and some properties of the iOS development-layer layer