你好,歡迎來到IOS教程網

 Ios教程網 >> IOS教程 >> 關於IOS教程 >> 仿iOS圖標抖動

仿iOS圖標抖動

編輯:關於IOS教程

仿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

以上所述就是本文的全部內容了,希望大家能夠喜歡。

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved