2010-11-02 110 views
0
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
CGFloat coef = tempCount/20; 
while(tempCount >= 0) 
{ 
    [imgView setTransform: CGAffineTransformRotate([imgView transform], -1*coef)]; 
    tempCount -=coef; 
    [NSThread sleepForTimeInterval: 0.09]; 
} 
} 

而問題是不是,更新的UIImageView我只循環後的圖像視圖更新圖像。我希望它每0.09秒更新一次。你能提出什麼?感謝名單!while循環運行

+0

你想做什麼?只是逐漸旋轉imageview? – Vladimir 2010-11-02 12:34:31

+0

是的,正好!我想在旋轉屏幕上顯示慢動畫。 – yozhik 2010-11-02 12:39:03

回答

0

如果要使用動畫旋轉視圖,請使用SDK爲您提供的動畫設施。要以完整360度旋轉視圖,您需要使用核心動畫。

3秒內將下面的代碼旋轉視圖:

#import <QuartzCore/QuartzCore.h> 
... 
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 
animation.fromValue = [NSNumber numberWithFloat:0.0f]; 
animation.toValue = [NSNumber numberWithFloat: 2*M_PI]; 
animation.duration = 3.0f; 
animation.repeatCount = 1.0f; 
[imgView.layer addAnimation:animation forKey:@"MyAnimation"]; 

或者試試下面的 - 我沒有測試的代碼,但它應該重新檢視的變換身份與動畫:

[UIView beginAnimations:@"Reset dial" context: nil]; 
[UIView setAnimationDuration: 1.0f]; 
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut]; 

[imgView setTransform:CGAffineTransformIdentity]; 

[UIView commitAnimations]; 
+0

不,我正嘗試用撥號電話撥打電話。在功能touchMoved我旋轉我的手機圈到右側,當我touchEnd我需要恢復我的形象到以前的角度,但有一些動畫延遲。 – yozhik 2010-11-02 12:49:06