UIViewPropertyAnimator的動(dòng)畫使用

1.彈出動(dòng)畫效果

ER7Rn2R.gif
/**
 彈出效果

 @param itemView 彈出的View
 @param center 彈出View的中心坐標(biāo)
 */
- (void)appearMenuItem:(UIView *)itemView andCenter:(CGPoint)center {
    
    UIViewPropertyAnimator *animator = [[UIViewPropertyAnimator alloc] initWithDuration:0.25 curve:UIViewAnimationCurveEaseOut animations:^{
        itemView.center = center;
    }];
    [animator startAnimation];//animator.startAnimation(afterDelay:2.5)//可以延遲出現(xiàn)
}

2.彈跳效果

732yYfe.gif
/**
 彈跳效果

 @param itemView 彈跳的View
 @param center 彈跳View的中心坐標(biāo)
 */
- (void)appearMenuItem:(UIView *)itemView andCenter:(CGPoint)center {
    
    UIViewPropertyAnimator *animator = [[UIViewPropertyAnimator alloc] initWithDuration:1 dampingRatio:0.4 animations:^{
        itemView.center = center;
    }];
    [animator startAnimation];//animator.startAnimation(afterDelay:2.5)//可以延遲出現(xiàn)
}

3.消失效果

Q3IjyuB.gif
/**
 消失效果

 @param itemView 消失的View
 @param center 消失View的中心坐標(biāo)
 */
- (void)appearMenuItem:(UIView *)itemView andCenter:(CGPoint)center {
    
    UIViewPropertyAnimator *animator = [[UIViewPropertyAnimator alloc] initWithDuration:2 curve:UIViewAnimationCurveEaseOut animations:^{
        itemView.alpha = 0;
    }];
    [animator addAnimations:^{
        itemView.center = center;
    }];
    [animator startAnimation];
}
最后編輯于
?著作權(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)容

  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫(kù)、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,293評(píng)論 4 61
  • 翻譯自“View Controller Programming Guide for iOS”。 1 彈出視圖控制器...
    lakerszhy閱讀 3,784評(píng)論 2 20
  • 現(xiàn)代社會(huì),女性受教育程度越來(lái)越高,工作能力也能抵男人半邊天,收入和地位自然也越來(lái)越高。自由戀愛(ài)的選擇也越來(lái)越多,這...
    千羽讀書閱讀 1,722評(píng)論 0 2
  • 前言 因?yàn)樯眢w原因,我不得不離開(kāi)我的公司,在離開(kāi)之前,我需要找到一個(gè)接手我項(xiàng)目的人。我出了兩套題,一套是用來(lái)找接手...
    筑夢(mèng)師Winston閱讀 3,760評(píng)論 14 23

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