Getting and some properties of the iOS development-layer layer

Source: Internet
Author: User
Tags border color

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

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.