开发者

spin image clockwise/anticlockwise on touch

Any idea about how to s开发者_如何学JAVApin image clockwise/anticlockwise on touch.


#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];


You'll want to use CoreAnimation for this; basically you'll need to apply an animation to the transform property of your image view. There are plenty of samples on Apple's developer page that show variations on this.


This may be the late answer to your question, but it will help someone..
By using the CGAffineTransformMakeRotation we can able to rotate the Image

Rotate the Image in Anti-Clockwise Direction

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

    }  

For ClockWise Direction use x--;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜