2011-11-18 33 views
0

我想在连接开始时旋转UIButton,并在连接停止时想要停止旋转。从服务器下载数据时的旋转按钮

所以我的问题是如何启动或停止UIButton旋转。

我使用下面的代码进行旋转。

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:5.0]; 

// (180 * M_PI)/180 == M_PI, so just use M_PI 
btn.transform = CGAffineTransformMakeRotation(M_PI); 

[UIView commitAnimations]; 

回答

2

你可以通过调用removeAllAnimations

[btn.layer removeAllAnimations]; 

确保您访问层属性之前导入QuartzCore删除从视图动画,否则你可能会得到一个警告。

#import <QuartzCore/QuartzCore.h> 

为了使视图动画连续使用上UIView+ (void)setAnimationRepeatCount:(float)repeatCount方法并将其设置为一些任意大量。

[UIView setAnimationRepeatCount:5000]; 
+0

感谢工作,但如何旋转按钮,直到下载完成,因为它只旋转一次 –

+0

嗯感谢了很多 –

相关问题