仿iOS圖標(biāo)抖動
更新時間:2015年05月27日 16:33:16 投稿:hebedich
最近閑來無聊,研究了一下IPhone桌面圖標(biāo)的抖動,網(wǎng)上有一個類似的事例,但是我看來效果實在不佳,自己也來寫一個玩玩,有需要的小伙伴可以參考下。
仿iOS圖標(biāo)抖動
#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)容了,希望大家能夠喜歡。
相關(guān)文章
設(shè)計模式中的Memento備忘錄模式的在iOS App開發(fā)中的運用
這篇文章主要介紹了設(shè)計模式中的Memento備忘錄模式的在iOS App開發(fā)中的運用,Memento著重于捕獲和具體化當(dāng)前對象的內(nèi)部狀態(tài),需要的朋友可以參考下2016-03-03
詳解2016 cocoapods的安裝和使用以及版本升級遇到的問題
CocoaPods是一個負(fù)責(zé)管理iOS項目中第三方開源庫的工具。這篇文章主要介紹了2016 cocoapods的安裝和使用以及版本升級遇到的問題,有需要的可以了解一下。2016-12-12
iOS實現(xiàn)動態(tài)自適應(yīng)標(biāo)簽
這篇文章主要為大家詳細(xì)介紹了iOS動態(tài)自適應(yīng)標(biāo)簽的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
改變iOS應(yīng)用中UITableView的背景顏色與背景圖片的方法
這篇文章主要介紹了改變iOS應(yīng)用中UITableView的背景顏色與背景圖片的方法,將UITableView的header、footer設(shè)成clearColor時要注意實際效果是否真的變透明,需要的朋友可以參考下2016-03-03

