美文网首页
Ios Layer之anchorPoint与position

Ios Layer之anchorPoint与position

作者: 王云晨 | 来源:发表于2017-08-22 16:58 被阅读0次

1.简单的理解

  • position设置CALayer 在父层中的位置
  • anchorPoint决定CALayer上的哪个点在position所指的位置上。自己的左上角为(0,0)。
         myLayer.anchorPoint = CGPointMake(1, 1)
图片.png

红色的图为棕色的图改变anchorPoint后的位置。

2.小结

  • anchorPoint 的默认值是(0.5,0.5),就是长方形的中心点。
  • position是layer中的anchorPoint在superLayer中的位置坐标。
  • layer的位置由position和anchorPoint共同决定frame.origin.x = position.x - anchorPoint.x *bounds.size.width

相关文章

网友评论

      本文标题:Ios Layer之anchorPoint与position

      本文链接:https://www.haomeiwen.com/subject/dsyldxtx.html