链接:写的好。看明白了。http://kittenyang.com/anchorpoint/
再复制一下结论。
![](https://img.haomeiwen.com/i3747146/e0aa8e3d512523d2.png)
总结
1、position是layer中的anchorPoint在superLayer中的位置坐标,其实就是没改变frame前的中心点。
2、anchorPoint是相对自身layer坐标系中的位置,坐标系如图。
2、互不影响原则:单独修改position与anchorPoint中任何一个属性都不影响另一个属性。
3、frame、position与anchorPoint有以下关系:
frame.origin.x = position.x - anchorPoint.x * bounds.size.width;
frame.origin.y = position.y - anchorPoint.y * bounds.size.height;
我的理解:狗尾续貂:通过这个公式可以看到position和anchor的修改都影响frame,但不影响对方。如果需要修改,但不影响frame,可以再把frame赋值成原来的值。
网友评论