触摸时顺时针/逆时针旋转图像

时间:2009-10-10 05:55:49

标签: iphone

关于如何在触摸时顺时针/逆时针旋转图像的任何想法。

3 个答案:

答案 0 :(得分:4)

#import <QuartzCore/QuartzCore.h> 

[UIView beginAnimations:@"RotationAnimation" context:nil];

CABasicAnimation *fullRotationAnimation;
fullRotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotationAnimation .fromValue = [NSNumber numberWithFloat:0];
fullRotationAnimation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotationAnimation.duration = 2;          // speed for the rotation. Smaller number is faster
fullRotationAnimation.repeatCount = 1e100f;  // number of times to spin. 1 = once
[myImage.layer addAnimation:fullRotationAnimation forKey:@"360"];

[UIView commitAnimations];

答案 1 :(得分:0)

你会想要使用CoreAnimation;基本上你需要将动画应用于图像视图的transform属性。 Apple的开发者页面上有很多samples,显示了相应的变化。

答案 2 :(得分:0)

这可能是你问题的迟到答案,但它会帮助某人..
通过使用CGAffineTransformMakeRotation,我们可以旋转图像

以逆时针方向旋转图像

-(void)rotate
    {
        x++;
        CGAffineTransform transform = CGAffineTransformMakeRotation(x);
        imageView.transform = transform;
        [self performSelector:@selector(rotate) withObject:self afterDelay:0.1];

    }  

对于ClockWise方向,请使用x - ;

相关问题