Thursday, September 3, 2009

Rotate an Image using Core Graphics in iPhone!!!

UIImage* rotatingImage = [UIImage imageNamed:@"someImage.png"];

CATransform3D rotationTransform
= CATransform3DMakeRotation(1.0f * M_PI, 0, 0, 1.0);
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

rotationAnimation
.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation
.duration = 0.25f;
rotationAnimation
.cumulative = YES;
rotationAnimation
.repeatCount = 10;

[rotatingImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

No comments:

Post a Comment