我的代码是这样的://ViewController.m//核心动画#import"ViewController.h"@interfaceViewController()@property(weak,nonatomic)IBOutletUIImageView*imageView;@end@implementationViewController-(void)viewDidLoad{[superviewDidLoad];}-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{[UIViewanimateWithDuration:3animations:^{self.imageView.layer.transform=CATransform3DMakeRotation(M_PI,0,1,1);}];}-(void)didReceiveMemoryWarning{[superdidReceiveMemoryWarning];}@end但是这样做旋转了一次就不在旋转了。请问如何实现不停的旋转呢?(按照Y轴)
2 回答
慕哥6287543
TA贡献1831条经验 获得超10个赞
[UIViewanimateWithDuration:3delay:0options:UIViewAnimationOptionRepeatanimations:^{}completion:^(BOOLfinished){}];
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
LZ的代码,并不是按照Y找转,Y,Z同时都会动,按Y轴循环转动,有以下两种方法可供参考,推荐第一种方法,过渡更平滑,自然.方法一:CABasicAnimation*rotationAnimation;rotationAnimation=[CABasicAnimationanimationWithKeyPath:@"transform.rotation.y"];rotationAnimation.toValue=[NSNumbernumberWithFloat:M_PI*2.0];rotationAnimation.duration=3;rotationAnimation.cumulative=YES;rotationAnimation.repeatCount=MAXFLOAT;[self.imageView.layeraddAnimation:rotationAnimationforKey:@"rotationAnimation"];方法二:[UIViewanimateWithDuration:3delay:0options:UIViewAnimationOptionRepeatanimations:^{self.imageView.layer.transform=CATransform3DMakeRotation(M_PI,0,1,0);}completion:^(BOOLfinished){self.imageView.layer.transform=CATransform3DMakeRotation(M_PI,0,1,0);}];
添加回答
举报
0/150
提交
取消