記錄幾個重要的 CALayer 屬性 (一)

記錄幾個 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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章