您的位置:首页 > 其它

记录几个重要的 CALayer 属性 (一)

2015-10-31 18:45 169 查看
记录几个 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 也随之改变, 具体详见我转载的一篇博客:

/article/10574176.html

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: