ShapeAnimation-SwiftSwift 矢量動畫框架
iOS上使用Swift實現的矢量圖形動畫框架,可動畫繪圖。
特點是可寫少量代碼實現常見的CoreAnimation層動畫,利用閉包定制動畫特性。
目前已支持下列動畫函數:
-
opacityAnimation, flashAnimation 透明度、閃爍
-
scaleAnimation 放縮
-
rotate360Degrees, rotationAnimation 旋轉
-
shakeAnimation 左右搖晃
-
moveAnimation, moveOnPathAnimation 沿路徑移動
-
slideToRight 向右滑動
-
strokeEndAnimation 沿線描繪
strokeColorAnimation, lineWidthAnimation, dashPhaseAnimation 線條顏色、線寬動畫,虛線動畫可用于亮顯選擇
-
switchPathAnimation 切換圖形
-
animationGroup 一個層多個動畫同時進行
-
applyAnimations 多個層同步動畫
該框架還在不斷更新中,歡迎Fork、點贊,歡迎動手和提建議。
代碼示例:
let layer1 = addLinesLayer(view, points:[(10.0,20.0),(150.0,40.0),(120.0,320.0)])
layer1.strokeEndAnimation().apply() {
layer1.shakeAnimation().apply()
}
let la2 = self.addLinesLayer(view, points:points2, color: UIColor.blueColor())
lla2.scaleAnimation(from:1, to:1.1, repeatCount:3).apply(duration:0.3)
let la3 = self.addLinesLayer(view, points:points3, color: UIColor.greenColor())
la3.flashAnimation(repeatCount:6).apply()
let la4 = addLinesLayer(view, points:[(10.0,20.0), (150.0,40.0), (120.0,120.0)])
let a1 = la4.moveOnPathAnimation(path).set {$0.duration=1.6}
let a2 = la4.rotate360Degrees().set {$0.repeatCount=2}
animationGroup([a1, a2]).set {$0.autoreverses=true}.apply()
評論
圖片
表情
