2010-11-02 148 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