iOS frame横缔、bounds、anchorPoint衫哥、position以及transform(全文)
1 frame
layer相對其父坐標(biāo)系的位置茎刚。包括矩形左上角點,矩形寬高撤逢。值得注意的是layer被旋轉(zhuǎn)后的寬高膛锭。如下圖所示粮坞,bounds是40*50,frame是62*64初狰。
2 bounds
layer相對其內(nèi)部坐標(biāo)系的位置莫杈。
3 anchorPoint
layer的錨點(默認(rèn)是{0.5, 0.5},即在layer的中部)相對其內(nèi)部單位坐標(biāo)系的位置奢入。錨點就是layer旋轉(zhuǎn)的中點筝闹。左上角是{0, 0},右下角是{1,1}腥光。值得注意的是錨點的值可以比0小关顷,比1大,例如{-0.5, 1.5}武福,如此layer旋轉(zhuǎn)可以圍繞外部某個點
4 position
layer的錨點相對其外部坐標(biāo)系的位置议双。
5 transform (3D變換)
6 CALayer的frame決定因素
view或者layer的frame其實不是一個獨立的屬性,它是由bounds艘儒、position和transform決定的虛擬屬性聋伦。因此,一旦以上3個屬性發(fā)生變化frame就會變化界睁。相反地,一旦改變frame兵拢,那么bounds翻斟、position和transform也可能變化。
The frame is not really a distinct property of the view or layer at all; it is a virtual property, computed from the bounds, position, and transform, and therefore changes when any of those properties are modified. Conversely, changing the frame may affect any or all of those values, as well.
7 參考文檔
Core Animation Programming Guide
《iOS Core Animation Advanced Techniques》