Calayer need to import this framework: #import <QuartzCore/QuartzCore.h>first, Calayer Common Properties
Properties |
Description |
whether implicit animations are supported |
Anchorpoint |
A point position coincident with the center point, called an "anchor point," where the anchor is described by default at the center point of the image (0.5,0.5) relative to the X, Y position ratio |
Is |
BackgroundColor |
Layer background color |
Is |
BorderColor |
Border color |
Is |
BorderWidth |
Border width |
Is |
Bounds |
Layer Size |
Is |
Contents |
Layers display content, such as the ability to display a picture as a layer content |
Is |
Contentsrect |
The size and position of the layer display content |
Is |
Cornerradius |
Fillet radius |
Is |
doublesided |
If the back of the layer is displayed, the default is Yes |
Whether |
Frame |
The layer size and position does not support implicit animation, so frame is rarely used in calayer, usually using bounds and position instead |
Whether |
Hidden |
Whether to hide |
Is |
Mask |
Layer Masks |
Is |
Masktobounds |
Whether sublayers cut layer boundaries, default to No |
Is |
Opacity |
Transparency, similar to the alpha of UIView |
Is |
Position |
The location of the center point of the layer, similar to the UIView |
Is |
Shadowcolor |
Shadow color |
Is |
Shadowoffset |
Shadow Offset |
Is |
Shadowopacity |
Shadow transparency, note the default is 0, this property must be set if the shadow is set |
Is |
Shadowpath |
Shape of the Shadow |
Is |
Shadowradius |
Shadow Blur Radius |
Is |
Sublayers |
Sub-layer |
Is |
Sublayertransform |
Child layer Deformation |
Is |
Transform |
Layer deformation |
Is |
Calayer, watch out.
- The nature of implicit property animation is that these properties are changed by default, cabasicanimation animation implementation is implied, so it appears to be animated, default 0.25 seconds
- The frame property is rarely used in Calayer because the frame itself does not support animation effects, usually using bounds and position instead.
- Transparency in Calayer uses opacity instead of alpha, and the center point uses a position representation instead of center.
- The Anchorpoint property is the anchor point of the layer, and the range in (0~1,0~1) represents the scale of the x and Y axes, which can always coincide with the position (center point), and when the center point of the layer is fixed, Adjust the anchorpoint to achieve the adjustment layer display position (because it is always coincident with position)
Second, the basic use of Calayer
2.1, the way of assigning valueSelf.iconView.layer.transform = Catransform3dmakescale (1.5, 0.5, 0) Self.iconView.layer.transform = Catransform3dmake Rotation (m_pi_4, 0, 0, 1)//3d rotation self.iconView.layer.shadowOpacity = 0.5; Set Shadow Transparency Self.iconView.layer.shadowColor = [Uicolor Bluecolor]. Cgcolor; Set Shadow Color Self.iconView.layer.shadowOffset = Cgsizemake (20, 20); Set Shadow Deviation
2.2, KVC Way[Self.iconView.layer setvalue:@ ( -100) forkeypath:@ "transform.translation.x"]; What parameters can be passed, see the official documentation
Basic use of Calayer