您的位置:首页 > 移动开发 > IOS开发

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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: