core animation 是在UIKit層之下的一個圖形庫,用於在iOS 和 OS X 實現動畫。html
Core Animation管理App內容ios
core animation不是一個完整的繪圖系統,它是將App內容合成、操縱並應用於硬件的一個基礎框架。git
他的核心是Layer對象,大多狀況,layer被用來管理view的內容,不過咱們仍然能夠建立獨立的layer。github
Layer 修改觸發動畫app
layer相似於view,有一些屬性能夠修改:bounds rectangle, a position onscreen, an opacity, a transform, and many other visually-oriented properties。框架
Layer能夠被組織劃分層次ide
layer的層次相似於view的層次,有parent-child的關係。post
Action 使咱們能夠改變Layer的默認特性動畫
隱式動畫由action完成,core animation使用action實現layer相關的動畫集合。action也能夠自定義。ui
爲Layer設置內容
1.給layer對象的contents屬性直接賦值爲image對象。(這種方式適合那種永遠或者不多變更的layer 內容)
2.給layer指定一個delegate,由delegate繪製layer的內容。(這種方式適合那種有周期變更的layer的內容,或者使用其餘對象提供給layer content的)
3.定義一個layer的子類,而且複寫繪製方法,從而建立內容。(這種方式適合你必需要子類化layer,或者你想改變layer的基本繪製機制)
CABasicAnimation :基本動畫
CAKeyframeAnimation :關鍵幀動畫
CATransitionAnimation :變換動畫
model layer 和 presenttation layer
Core Animation 維護了兩個平行 layer 層次結構:
1.model layer tree(模型層樹)
2.presentation layer tree(表示層樹)
關於postion、anchorpoint的一個文章,不錯:
http://wonderffee.github.io/blog/2013/10/13/understand-anchorpoint-and-position/
fromValue toValue byValue
1.fromValue toValue都不爲nil,改變將會是從fromValue->toValue
2.fromValue byValue都不爲nil,改變將會是從fromValue->(fromValue+byValue)
3.byValue toValue不爲nil,改變將會是從(toValue-byValue)->toValue
4.fromValue不爲nil,改變將會是從fromValue->當前展現位置的value
5.toValue不爲nil,改變將會是從當前展現的value->toValue
6.byValue不爲nil,改變將是會從當前展現的value->當前展現的value+byValue
7.fromValue toValue byValue都爲nil,改變是從以前的value->當前設置的value
CATransform3D
參考:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
http://zsisme.gitbooks.io/ios-/content/index.html
http://objccn.io/issue-12-1/
http://blog.sina.com.cn/s/blog_a5243c7f0102v17c.html