iOS動(dòng)畫(huà)-定時(shí)對(duì)UIView進(jìn)行翻轉(zhuǎn)和抖動(dòng)的方法
(翻轉(zhuǎn))方式一:
[NSTimer scheduledTimerWithTimeInterval:3.f repeats:YES block:^(NSTimer * _Nonnull timer) { CABasicAnimation* rotationAnimation = [CABasicAnimation animation];; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation.duration = 1; // 切換界面保證動(dòng)畫(huà)不停止 rotationAnimation.removedOnCompletion = NO; rotationAnimation.repeatCount = 1; [self.bindCardImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; }];
(翻轉(zhuǎn))方式二(這種方式較好一些):
CABasicAnimation *waitAnimation = [CABasicAnimation animation]; waitAnimation.toValue = [NSNumber numberWithFloat:1.0]; waitAnimation.duration = 3.f; waitAnimation.beginTime = 3.f; CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation.duration = 1.f; CAAnimationGroup *group = [CAAnimationGroup animation]; group.duration = 4.f; group.repeatCount = CGFLOAT_MAX; group.removedOnCompletion = NO; [group setAnimations:@[waitAnimation, rotationAnimation]]; [self.bindCardImageView.layer addAnimation:group forKey:@"bindCardImageViewAnimation"];
抖動(dòng):
CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //設(shè)置抖動(dòng)幅度 shake.fromValue = [NSNumber numberWithFloat:-0.2]; shake.toValue = [NSNumber numberWithFloat:+0.2]; shake.duration = 0.1; shake.autoreverses = YES; //是否重復(fù) shake.repeatCount = 3; [itemView.iconImageView.layer addAnimation:shake forKey:@"imageView"];
以上這篇iOS動(dòng)畫(huà)-定時(shí)對(duì)UIView進(jìn)行翻轉(zhuǎn)和抖動(dòng)的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- iOS實(shí)現(xiàn)支付寶螞蟻森林隨機(jī)按鈕及抖動(dòng)效果
- 詳解iOS中position:fixed吸底時(shí)的滑動(dòng)出現(xiàn)抖動(dòng)的解決方案
- iOS實(shí)現(xiàn)自定義購(gòu)物車(chē)角標(biāo)顯示購(gòu)物數(shù)量(添加商品時(shí)角標(biāo)抖動(dòng) Vie)
- iOS字體抖動(dòng)動(dòng)畫(huà)的實(shí)現(xiàn)代碼
- IOS倒計(jì)時(shí)設(shè)置UIButton標(biāo)題title的抖動(dòng)問(wèn)題
- iOS自定義button抖動(dòng)效果并實(shí)現(xiàn)右上角刪除按鈕
- 仿iOS圖標(biāo)抖動(dòng)
- iOS實(shí)現(xiàn)圖片抖動(dòng)效果
相關(guān)文章
iOS應(yīng)用程序之間的幾種跳轉(zhuǎn)情況詳解
這篇文章給大家詳細(xì)介紹了iOS應(yīng)用程序之間跳轉(zhuǎn)的幾種情況,包括跳轉(zhuǎn)到另一個(gè)程序的主界面、跳轉(zhuǎn)到另一個(gè)程序的指定界面以及如何從目標(biāo)程序的非主頁(yè)界面回到當(dāng)前(跳轉(zhuǎn)前)程序呢?有需要的朋友們可以下面來(lái)一起看看。2016-09-09移動(dòng)端固定輸入框在底部會(huì)被鍵盤(pán)遮擋的解決方法(必看篇)
下面小編就為大家分享關(guān)于移動(dòng)端固定輸入框在底部會(huì)被鍵盤(pán)遮擋的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12Unity3D實(shí)驗(yàn)室之iOS真機(jī)閃退的解決方法
下面小編就為大家分享一篇Unity3D實(shí)驗(yàn)室之iOS真機(jī)閃退的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02Xcode中iOS應(yīng)用開(kāi)發(fā)的一般項(xiàng)目目錄結(jié)構(gòu)和流程簡(jiǎn)介
這篇文章主要介紹了Xcode中iOS應(yīng)用開(kāi)發(fā)的一般項(xiàng)目目錄結(jié)構(gòu)和流程簡(jiǎn)介,包括項(xiàng)目所需的一些平臺(tái)路徑如模擬器路徑等的介紹,需要的朋友可以參考下2016-02-02深入學(xué)習(xí)iOS7自定義導(dǎo)航轉(zhuǎn)場(chǎng)動(dòng)畫(huà)
這篇文章主要為大家詳細(xì)介紹了iOS7自定義導(dǎo)航轉(zhuǎn)場(chǎng)動(dòng)畫(huà)的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-02-02iOS開(kāi)發(fā)中一些手寫(xiě)控件及其相關(guān)屬性的使用
這篇文章主要介紹了iOS開(kāi)發(fā)中一些手寫(xiě)控件及其相關(guān)屬性的使用,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12