Introduction of Ios-calayer

Source: Internet
Author: User

I. Introduction of Calayer

    • In iOS, what you can see and touch is basically uiview, such as a button, a text label, a text input box, an icon, and so on, which are all UIView
    • In fact, UIView can be displayed on the screen entirely because of a layer inside it
    • When you create a UIView object, a layer (that is, the Calayer object) is automatically created inside UIView, which can be accessed through the Layer property of UIView.

  @property (Nonatomic,readonly,retain) Calayer *layer;

    • When UIView needs to be displayed on the screen, the DrawRect: method is called to draw, and all the content is drawn on its own layer, and after the drawing is finished, the layer is copied to the screen, so the display of the UIView is completed.
    • In other words, the UIView itself does not have the function of the display, it is the inner layer of the display function

Second, the basic use of Calayer

    • By manipulating the Calayer object, you can easily adjust some of the appearance properties of the UIView
    • You can also animate layers to achieve some cool results.

Iii. attributes of Calayer

    • Width and height

@property cgrect bounds;

    • Location (default midpoint, determined by Anchorpoint)

@property cgpoint position;

    • The anchor Point (x, y range is 0-1), which determines the meaning of the position

@property Cgpoint Anchorpoint;

    • Background color (cgcolorref type)

@property Cgcolorref BackgroundColor;

    • Deformation properties

@property Catransform3d Transform;

    • Border color (cgcolorref type)

@property Cgcolorref bordercolor;

    • Border width

@property CGFloat borderWidth;

    • Content (e.g. set as Picture cgimageref)

@property (retain) ID contents;

  The introduction of Calayer has 2 very important properties: position and Anchorpoint

@property cgpoint position;

Used to set the position of the Calayer in the parent layer, with the upper-left corner of the parent layer as the origin (0, 0)

@property Cgpoint Anchorpoint;

Known as Anchor Point, Anchor Point

Determines which point of the calayer is in the position indicated by the position attribute

In its own upper left corner as the origin (0, 0)

Its x, y range is 0~1, the default value is (0.5, 0.5)

Iv. doubts about the Calayer

First of all

    • Calayer is defined in the Quartzcore framework.
    • Cgimageref, cgcolorref Two types of data are defined in the Coregraphics framework.
    • Uicolor, uiimage are defined in the Uikit framework.

Secondly

    • The Quartzcore framework and Coregraphics framework are available across platforms and can be used on both iOS and Mac OS x.
    • But Uikit can only be used in iOS

In order to ensure portability, Quartzcore cannot use UIImage, Uicolor, can only use Cgimageref, Cgcolorref

Introduction of Ios-calayer

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.