记录几个 CALayer 的重要属性
有关图层的几何结构
- frame : 配置本层的相对于 superlayer 的位置信息及层的大小
@property CGRect frame;
/* Unlike NSView, each Layer in the hierarchy has an implicit frame
* rectangle, a function of the `position', `bounds', `anchorPoint',
* and `transform' properties. When setting the frame the `position'
* and `bounds.size' are changed to match the given frame. */
每一个图层都有 一个隐式的 super layer, 都有 position, bounds, anchorPoint, transform 属性.当 frame 改变时, position, bouns.size 也随之改变, 具体详见我转载的一篇博客:
http://blog.csdn.net/u010358868/article/details/49534003
CALayer *subLayer = [CALayer layer];
NSLog(@"%.2f, %.2f, %.2f, %.2f", subLayer.frame.origin.x,
subLayer.frame.origin.y, subLayer.frame.size.width,
subLayer.frame.size.height);//也可以进行设置, 同样需要设置以上4个值.
subLayer.frame = CGRectMake(10, 10, 100, 100);
- bounds : 配置本层的位置信息及层的大小
@property CGRect bounds;
/* The bounds of the layer. Defaults to CGRectZero. Animatable. */
默认值为 CGRectZero (0.0, 0.0, 0.0, 0.0)
CALayer *subLayer = [CALayer layer];
NSLog(@"%.2f, %.2f, %.2f, %.2f", subLayer.bounds.origin.x,
subLayer.bounds.origin.y, subLayer.bounds.size.width,
subLayer.bounds.size.height);