仿iOS图标抖动 仿iOS图标抖动

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

仿iOS图标抖动 仿iOS图标抖动

  2021-03-21 我要评论
想了解仿iOS图标抖动的相关内容吗,在本文为您仔细讲解仿iOS图标抖动的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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

以上所述就是本文的全部内容了,希望大家能够喜欢。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们