內容大綱:html
四、用於CAShapeLayer的貝塞爾曲線作爲path,其path實一個首尾相接的閉環的曲線,即便該貝塞爾曲線不是一個閉環的曲線git
圖2.pnggithub
如何創建貝塞爾曲線和CAShapeLayer的聯繫:框架
屬性:pathpost
UIBezierPath *circle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0,200,100)]; shape.path = circle.CGPath;
屬性:fillColor 修改貝塞爾曲線的填充顏色優化
屬性:maskToBounds 動畫
四、將strokeStart值設定成0,而後讓strokeEnd的值變化觸發隱式動畫spa
類:CAShapeLayer3d
屬性:code
處理方法:
shapeLayer.strokeStart = valueOne < valueTwo ? valueOne : valueTwo; shapeLayer.strokeStart = valueOne > valueTwo ? valueOne : valueTwo;
屬性:
圓形進度條動畫.gif
源碼下載地址:CircleProgress 中的 CircleProgress源碼
直接更改path的結果,並無理想中的漸變過程,因此須要使用核心動畫:
綜合示例源碼請看:https://github.com/HeYang123456789/UIView
若是fillColors不設置成 [UIColor clearColor].CGColor就會有這樣的效果: