CABasicAnimation

CABasicAnimation

  • 父類是CAPropertyAnimation

CABasicAnimation——基本動(dòng)畫

  • 基本動(dòng)畫,是CAPropertyAnimation的子類

  • 屬性說明:

    • fromValue:keyPath相應(yīng)屬性的初始值
    • toValue:keyPath相應(yīng)屬性的結(jié)束值
  • 動(dòng)畫過程說明:

    • 隨著動(dòng)畫的進(jìn)行,在長(zhǎng)度為duration的持續(xù)時(shí)間內(nèi),keyPath相應(yīng)屬性的值從fromValue漸漸地變?yōu)閠oValue
    • keyPath內(nèi)容是CALayer的可動(dòng)畫Animatable屬性
    • 如果fillMode=kCAFillModeForwards同時(shí)removedOnComletion=NO,那么在動(dòng)畫執(zhí)行完畢后,圖層會(huì)保持顯示動(dòng)畫執(zhí)行后的狀態(tài)。但在實(shí)質(zhì)上,圖層的屬性值還是動(dòng)畫執(zhí)行前的初始值,并沒有真正被改變。

CABasicAnimation實(shí)現(xiàn)形變效果

    // 1.創(chuàng)建核心動(dòng)畫
    CABasicAnimation *anim = [CABasicAnimation animation];

    // 2.描述修改Layer哪個(gè)屬性
    anim.keyPath = keyPath(_redView.layer, position);
##核心代碼
    // 3.描述修改layer屬性的值
    // 動(dòng)畫的起點(diǎn)
    //    anim.fromValue =
    // 動(dòng)畫的終點(diǎn)
    anim.toValue = [NSValue valueWithCGPoint:CGPointMake(300, 400)];

    // 動(dòng)畫時(shí)長(zhǎng)
    anim.duration = 1;

    // 取消反彈
    // 1.在動(dòng)畫完成的時(shí)候不要給我把動(dòng)畫銷毀
    anim.removedOnCompletion = NO;

    // 2.動(dòng)畫永遠(yuǎn)保持最新的狀態(tài)
    anim.fillMode = kCAFillModeForwards;
##

    // 添加核心動(dòng)畫
    [_redView.layer addAnimation:anim forKey:nil];

CABasicAnimation實(shí)現(xiàn)縮放-心臟跳動(dòng)效果

    // 1.創(chuàng)建動(dòng)畫對(duì)象
    CABasicAnimation *anim = [CABasicAnimation animation];

    // 2.描述修改layer的屬性
    anim.keyPath = keyPath(_imageView.layer, transform);
##核心代碼
    // 3.修改layer的值
    anim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 1)];

    // 設(shè)置動(dòng)畫執(zhí)行次數(shù)
    anim.repeatCount = MAXFLOAT;

    //自動(dòng)翻轉(zhuǎn)
    anim.autoreveres = YES;
##
    // 4.添加到圖層
    [_imageView.layer addAnimation:anim forKey:nil];
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

  • 在iOS中隨處都可以看到絢麗的動(dòng)畫效果,實(shí)現(xiàn)這些動(dòng)畫的過程并不復(fù)雜,今天將帶大家一窺iOS動(dòng)畫全貌。在這里你可以看...
    F麥子閱讀 5,267評(píng)論 5 13
  • 本文轉(zhuǎn)載自:http://www.cocoachina.com/ios/20150105/10812.html 為...
    idiot_lin閱讀 1,377評(píng)論 0 1
  • 最近一直在看關(guān)于CALayer的相關(guān)知識(shí),這里整理一下CABasicAnimation相關(guān)知識(shí)1.CAlayer2...
    Zhui_Do閱讀 11,246評(píng)論 1 21
  • 一、簡(jiǎn)介 CABasicAnimation是CAPropertyAnimation的子類, CAPropertyA...
    iOS_成才錄閱讀 7,222評(píng)論 0 11
  • 在iOS實(shí)際開發(fā)中常用的動(dòng)畫無非是以下四種:UIView動(dòng)畫,核心動(dòng)畫,幀動(dòng)畫,自定義轉(zhuǎn)場(chǎng)動(dòng)畫。 1.UIView...
    請(qǐng)叫我周小帥閱讀 3,315評(píng)論 1 23

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