仿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
以上所述就是本文的全部内容了,希望大家能够喜欢。
上一篇: ios中图像进行压缩方法汇总
下一篇: IOS关闭键盘的方法