亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何實現圖片的3D旋轉,而且是不停旋轉?

如何實現圖片的3D旋轉,而且是不停旋轉?

牛魔王的故事 2019-04-19 16:29:44
我的代碼是這樣的://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:3
delay:0
options:UIViewAnimationOptionRepeat
animations:^{
}
completion:^(BOOLfinished){
}];
                            
查看完整回答
反對 回復 2019-04-19
?
尚方寶劍之說

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:3
delay:0
options:UIViewAnimationOptionRepeat
animations:^{
self.imageView.layer.transform=CATransform3DMakeRotation(M_PI,0,1,0);
}
completion:^(BOOLfinished){
self.imageView.layer.transform=CATransform3DMakeRotation(M_PI,0,1,0);
}];
                            
查看完整回答
反對 回復 2019-04-19
  • 2 回答
  • 0 關注
  • 681 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號