diana
diana

Reputation: 427

spin image clockwise/anticlockwise on touch

Any idea about how to spin image clockwise/anticlockwise on touch.

Upvotes: 0

Views: 2154

Answers (3)

Aravindhan
Aravindhan

Reputation: 15628

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

Upvotes: 0

runmad
runmad

Reputation: 14886

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

Upvotes: 4

Ben Gottlieb
Ben Gottlieb

Reputation: 85532

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.

Upvotes: 0

Related Questions