position和anchorPoint

CALayer有2个非常重要的属性:position和anchorPoint

 

@property CGPoint position;

用来设置CALayer在父层中的位置

以父层的左上角为原点(0, 0)

 

@property CGPoint anchorPoint;

称为“定位点”、“锚点”

决定着CALayer身上的哪个点会在position属性所指的位置

以自己的左上角为原点(0, 0)

它的x、y取值范围都是0~1,默认值为(0.5, 0.5)

 

 

红色图层的anchorPoint是(0,0)

红色图层的anchorPoint是(0.5,0.5)

红色图层的anchorPoint是(1,1)

红色图层的anchorPoint是(0.5,0)

红色图层的anchorPoint是(1,0.5)

 

posted @ 2015-03-15 13:02  LennyKwok  阅读(121)  评论(0)    收藏  举报