欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

仿iOS图标抖动

程序员文章站 2022-03-02 15:05:16
仿ios图标抖动 #import "lhviewcontroller.h" #define angeltorandian(x) ((x)/180.0*m_pi)...

仿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

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