iOS動(dòng)畫-定時(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)畫不停止
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)畫-定時(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)物車角標(biāo)顯示購(gòu)物數(shù)量(添加商品時(shí)角標(biāo)抖動(dòng) Vie)
- iOS字體抖動(dòng)動(dòng)畫的實(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)用腳本重簽名的實(shí)現(xiàn)方法
這篇文章主要介紹了iOS應(yīng)用腳本重簽名的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01
iOS判斷運(yùn)營(yíng)商類型的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇iOS判斷運(yùn)營(yíng)商類型的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-04-04
iOS動(dòng)態(tài)調(diào)整UILabel高度的幾種方法
在iOS編程中UILabel是一個(gè)常用的控件,下面這篇文章主要給大家介紹了關(guān)于iOS動(dòng)態(tài)調(diào)整UILabel高度的幾種方法,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-12-12
iOS中使用Fastlane實(shí)現(xiàn)自動(dòng)化打包和發(fā)布
Fastlane是一套使用Ruby寫的自動(dòng)化工具集,用于iOS和Android的自動(dòng)化打包、發(fā)布等工作,可以節(jié)省大量的時(shí)間。下面給大家介紹ios fastlane 自動(dòng)化打包和發(fā)布的安裝方法,需要的朋友參考下吧2017-05-05
Objective-C中NSNumber與NSDictionary的用法簡(jiǎn)介
iOS中的AutoLayout使用實(shí)踐總結(jié)
iOS AVPlayer切換播放源實(shí)現(xiàn)連續(xù)播放和全屏切換的方法

