iOS 实现转盘的效果
2016-06-14 08:42
323 查看
效果
![](https://images2015.cnblogs.com/blog/818241/201606/818241-20160614084010213-1492327530.gif)
![](https://images2015.cnblogs.com/blog/818241/201606/818241-20160614084010213-1492327530.gif)
#import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *panImageView; /** */ @property(nonatomic,assign)int angle; /** 转盘时间 */ @property(strong,nonatomic)NSTimer *timer; /** 计时器 */ @property(strong,nonatomic)NSTimer *timeTick; /** 计时时间 */ @property(nonatomic,assign)int timeNumber; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.timeNumber = 3; self.timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startAnimation) userInfo:nil repeats:YES]; self.timeTick = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES]; } -(void)startAnimation { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1]; [UIView setAnimationDelegate:self]; _panImageView.animationRepeatCount = 1; // [UIView setAnimationDidStopSelector:@selector(startAnimation)]; self.angle += 1000; self.panImageView.layer.anchorPoint = CGPointMake(0.5,0.5);//以右下角为原点转,(0,0)是左上角转,(0.5,0,5)心中间转,其它以此类推 self.panImageView.transform = CGAffineTransformMakeRotation(self.angle * (M_PI / 180.0f)); [UIView commitAnimations]; } -(void)timeFireMethod{ self.timeNumber -- ; if (self.timeNumber == 0) { [self.timer invalidate]; } } @end
相关文章推荐
- cocoapods安装使用
- iOS程序灵魂之性能优化
- iOS开发--QQ音乐练习,后台播放和锁屏界面
- iOS开发--QQ音乐练习,歌词的展示,歌词的滚动,歌词的颜色变化
- iOS二维码扫描
- Ios中CRC校验方法
- [一句秒懂]拦截iOS系统导航栏返回按钮事件-三种方法
- xcode7 ios9 iOS中设计模式中委托模式(同一工作空间不同工程)异步调用
- 升级开发者版本的Xcode,iOS,macOS...
- 自定义NavgationBar
- iOS打开系统相册显示中文方法
- ios中json解析出现的null问题
- iOS强制横屏API不起作用
- iOS开发bundle identifier修改不了(解决bundle ID无法修改的问题)
- iOS开发小技巧--定时器的使用技巧
- iOS开发--QQ音乐练习,旋转动画的实现,音乐工具类的封装,定时器的使用技巧,SliderBar的事件处理
- iOS开发小技巧-修改SliderBar指针的样式(牢记这个方法,只能通过代码来修改)
- iOS 设计模式系列:Command – 命令模式
- iOS开发小技巧--实现毛玻璃效果的方法
- iOS开发--音乐文件播放工具类的封装(包含了音效的封装)