- anchorpoint是什么
All geometric manipulations to the view occur about the specified point
就是說所有的動畫參考點都是anchorpoint。比如說旋轉動畫,就是說所有的點都圍繞這個點做動畫;再比如說縮放,就是說所有的點到錨點的距離變為原來的多少倍。
-
anchorPoint和動畫
- anchorpoint和frame、bounds、position
每一個view都有對應的layer,layer的delegate是view。可以理解為訪問、改變view的屬性其實是在訪問、改變layer的屬性,只不過view可以相應點擊事件。
view的屬性frame
,bounds
,center
實際上就是layer的frame
,bounds
,position
屬性。
anchorpoint
是一個點,是相對位置,即{0,0}是左上角,{1,1}是右下角。一個layer的anchorpoint
和position
是同一個點,只不過是在不同的坐標系下。anchorpoint
在bounds的單位坐標系下,position
是在super layer的坐標下。
改變anchorpoint
時,position
不會改變,而是會改變frame
的原點。滿足frame.origin.x = position.x - anchorPoint.x*bounds.size.width
。
改變anchorpoint改變frame原點 - 利用anchorpoint免去復雜的變換
- 資料