仿iOS圖標抖動
更新時間:2015年05月27日 16:33:16 投稿:hebedich
最近閑來無聊,研究了一下IPhone桌面圖標的抖動,網(wǎng)上有一個類似的事例,但是我看來效果實在不佳,自己也來寫一個玩玩,有需要的小伙伴可以參考下。
仿iOS圖標抖動
#import "LHViewController.h" #define angelToRandian(x) ((x)/180.0*M_PI) @interface LHViewController () @property (strong, nonatomic) IBOutlet UIImageView *imageView; @end @implementation LHViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UILongPressGestureRecognizer* longPress=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPress:)]; [self.imageView addGestureRecognizer:longPress]; } -(void)longPress:(UILongPressGestureRecognizer*)longPress { if (longPress.state==UIGestureRecognizerStateBegan) { CAKeyframeAnimation* anim=[CAKeyframeAnimation animation]; anim.keyPath=@"transform.rotation"; anim.values=@[@(angelToRandian(-7)),@(angelToRandian(7)),@(angelToRandian(-7))]; anim.repeatCount=MAXFLOAT; anim.duration=0.2; [self.imageView.layer addAnimation:anim forKey:nil]; self.btn.hidden=NO; } } - (IBAction)delete:(id)sender { [self.imageView removeFromSuperview]; [self.btn removeFromSuperview]; } @end
以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。
相關文章
設計模式中的Memento備忘錄模式的在iOS App開發(fā)中的運用
這篇文章主要介紹了設計模式中的Memento備忘錄模式的在iOS App開發(fā)中的運用,Memento著重于捕獲和具體化當前對象的內(nèi)部狀態(tài),需要的朋友可以參考下2016-03-03詳解2016 cocoapods的安裝和使用以及版本升級遇到的問題
CocoaPods是一個負責管理iOS項目中第三方開源庫的工具。這篇文章主要介紹了2016 cocoapods的安裝和使用以及版本升級遇到的問題,有需要的可以了解一下。2016-12-12改變iOS應用中UITableView的背景顏色與背景圖片的方法
這篇文章主要介紹了改變iOS應用中UITableView的背景顏色與背景圖片的方法,將UITableView的header、footer設成clearColor時要注意實際效果是否真的變透明,需要的朋友可以參考下2016-03-03