用基础动画实现iOS控件循环旋转
2015-12-09 13:48
656 查看
- (void)viewDidLoad { [super viewDidLoad]; UIButton* ag=[[UIButton alloc]initWithFrame:CGRectMake(screenWidth/2-75, 174, 150, 150)]; UIImage* img=[UIImage imageNamed:@"m_01"]; [ag setImage:img forState:UIControlStateNormal]; ag.backgroundColor=[UIColor redColor]; [self rotate360DegreeWithButton:ag]; [self.view addSubview:ag]; } - (UIButton*)rotate360DegreeWithButton:(UIButton*)button { CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.toValue = [NSNumber numberWithFloat:M_PI]; animation.duration = 10; //旋转效果累计 先转180度 接着再旋转180度 从而实现360旋转 animation.cumulative = YES; animation.repeatCount = 1000; [button.layer addAnimation:animation forKey:@"transform.rotation.z"]; return button; }
相关文章推荐
- iOS Tips
- 2015-12-IOS 获取最新设备型号方法
- IOS_多线程编程4 - GCD
- iOS开发-工具:Xcode7升级之后插件无法使用与不小心点击Skipbundle的解决办法
- iOS 中二维码扫描
- ios加密后的数据保存本地,解密时为何失败
- iOS Autolayout基础-Masonry
- IOS_多线程编程2 - NSOperation
- ios9 的新特性
- IOS 多线程编程1 - NSThread
- iOS CoreData 存取数组字典等数据类型
- 分享一下我封装iOS自定义控件的体会,附上三个好用的控件Demo <时间选择器&多行输入框&日期选择器>
- iOS立方体翻转3D特效
- iOS 在Xcode中添加多个模拟器
- ios同一个Label中的字符设置不同的字体
- iOS 保持界面流畅的技巧(转)
- iOS-布局-Masonry
- 导航栏透明 毛玻璃效果iOS
- ios正在使用NSDateComponents、NSDate、NSCalendar它的结论是在当前时间是在一段时间在一天。
- ios判断是否展示轮播图