2011-11-18 32 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

嗯感謝了很多 –

相關問題