CAShapeLayer之strokeStart和strokeEnd屬性研究

CAShapeLayer之strokeStart和strokeEnd屬性研究


galshir-todo-list-swipe.gif

最近利用閑暇在研究上面的這個(gè)動(dòng)畫,因?yàn)楸旧韺?dòng)畫沒有太深入的研究。
該動(dòng)畫是來自一個(gè)設(shè)計(jì)師的設(shè)計(jì)作品:https://dribbble.com/shots/3959132-Todo-List-Swipe-To-Check
覺得很nice

在研究這個(gè)動(dòng)畫的過程中涉及到了UIBezierPath,CAKeyframeAnimation,CAShapeLayer,CATransaction等系統(tǒng)類

先不表這個(gè)動(dòng)畫的思路

本文單開是為了介紹CAShapeLayer的strokeStart和strokeEnd屬性

官方文檔

  • strokeStart
    The relative location at which to begin stroking the path. Animatable.
  • strokeEnd
    The relative location at which to stop stroking the path. Animatable.
  1. keyPath = strokeStart,keytimes=[@"0", @"1"];
  • values = [@"0",@"1"];
    strokeEnd默認(rèn)為1,strokeStart:0~1
    strokeStart = 0 時(shí)有一條完整的路徑
    strokeStart = 1 時(shí) 路徑消失。
    效果就是一條從路徑起點(diǎn)到終點(diǎn)慢慢的消失
  • values = [@"1",@"0"];
    strokeEnd默認(rèn)為1,strokeStart從 1 到 0 ,
    strokeStart = 1 時(shí)無路徑
    strokeStart = 0 時(shí) 畫出一條完整的路徑。
    效果就是一條從路徑終點(diǎn)到起點(diǎn)慢慢的出現(xiàn)
  1. keyPath = strokeEnd,keytimes=[@"0", @"1"];
  • values = [@"0",@"1"];
    strokeStart默認(rèn)為0,strokeEnd從 0-1,
    strokeEnd=0 時(shí),無路徑,
    strokeEnd=1 時(shí),一條完整路徑。
    效果就是一條路徑起點(diǎn)到終點(diǎn)慢慢的出現(xiàn)
  • values = [@"1",@"0"];
    strokeStart默認(rèn)為0,strokeEnd從 1-0,
    strokeEnd=1 時(shí),有路徑,
    strokeEnd=0 時(shí),無路徑。
    效果就是一條路徑終點(diǎn)到起點(diǎn)慢慢的消失

效果圖如下:

動(dòng)畫的0-1(fromValue = 0,toValue = 1) 或1-0 (fromValue = 1,toValue = 0) 表示執(zhí)行的方向 和路徑的范圍。

放出研究到一半的動(dòng)畫:

QQ20181019-130017-HD.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容