iOS 旋转动画
2015-08-06 17:32
363 查看
-(void)timed{
timers=[NSTimer
scheduledTimerWithTimeInterval:1
target:self
selector:@selector(mytimer)
userInfo:nil
repeats:YES];
}
-(void)mytimer{
count ++;
int x=self.view.frame.size.width;
int y=self.view.frame.size.height;
int number=arc4random()%x;
int bbbb=arc4random()%y;
int hahahh=(arc4random()%80)+30;
UIImageView * _loadingView = [[UIImageView
alloc]initWithFrame:CGRectMake(number-hahahh,bbbb-hahahh, hahahh, hahahh)];
_loadingView.image = [UIImage
imageNamed:@"rotating"];
[self.view
addSubview:_loadingView];
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber
numberWithFloat: M_PI *
2.0 ];
rotationAnimation.duration =
2;
rotationAnimation.cumulative =
YES;
rotationAnimation.repeatCount =
100000;
[_loadingView.layer
addAnimation:rotationAnimation
forKey:@"rotationAnimation"];
[self
performSelector:@selector(closed:)
withObject:_loadingView afterDelay:1];
// if (count+=2) {//这里怎么判断
// [_loadingView.layer removeAnimationForKey:@"rotationAnimation"];
// [_loadingView removeFromSuperview];
//
// }
}
-(void)closed:(UIImageView *)imageView{
[imageView removeFromSuperview];
}
timers=[NSTimer
scheduledTimerWithTimeInterval:1
target:self
selector:@selector(mytimer)
userInfo:nil
repeats:YES];
}
-(void)mytimer{
count ++;
int x=self.view.frame.size.width;
int y=self.view.frame.size.height;
int number=arc4random()%x;
int bbbb=arc4random()%y;
int hahahh=(arc4random()%80)+30;
UIImageView * _loadingView = [[UIImageView
alloc]initWithFrame:CGRectMake(number-hahahh,bbbb-hahahh, hahahh, hahahh)];
_loadingView.image = [UIImage
imageNamed:@"rotating"];
[self.view
addSubview:_loadingView];
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber
numberWithFloat: M_PI *
2.0 ];
rotationAnimation.duration =
2;
rotationAnimation.cumulative =
YES;
rotationAnimation.repeatCount =
100000;
[_loadingView.layer
addAnimation:rotationAnimation
forKey:@"rotationAnimation"];
[self
performSelector:@selector(closed:)
withObject:_loadingView afterDelay:1];
// if (count+=2) {//这里怎么判断
// [_loadingView.layer removeAnimationForKey:@"rotationAnimation"];
// [_loadingView removeFromSuperview];
//
// }
}
-(void)closed:(UIImageView *)imageView{
[imageView removeFromSuperview];
}
相关文章推荐
- iOS 从应用程序跳转到评价界面
- iOS 第二课 单例写法 本地存储登入登出 第三方缓冲圈
- 一些iOS常用的第三方库和控件
- iOS 工具类 SSToolkit
- [IOS 开发] XCTAssert单元测试
- iOS开发——如何切图适配各种机型
- iOS tableviewcell重用机制避免重复显示
- IOS多线程知识总结/队列概念/GCD/主队列/并行队列/全局队列/主队列/串行队列/同步任务/异步任务区别
- ios 获得设备型号方法
- iOS常用第三方类库及Xcode插件
- 修复iOS7、iOS8下leftBarButtonItem位置相比之前版本靠右的问题
- 关于iOS的多线程处理方式
- Drogon——利用 method swizzling 解决 iOS APP 限制 URL 跳转的问题
- iOS 合并带有透明通道的视频-
- IOS学习之ios应用数据存储方式(归档)
- ios 清理缓存
- OC之使用MD5加密字符串、NSData和文件的方法
- IOS学习之ios应用数据存储方式(偏好设置)
- IOS学习之ios应用数据存储方式(XML属性列表-plist)
- iOS设计模式之单例模式