Tuesday 8 April 2014

Rotate the UIView clockwise. Rotate or swing UIView in circular manner.

#define DEGREES_TO_RADIANS(degree) (M_PI * degree / 180.0)

#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))




+(void)rotateViewLikeCircle:(UIView*)view rotation:(int)numberOfRotation
{
    CABasicAnimation *rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(180)];
    rotationAnimation.duration = 0.75;
    rotationAnimation.repeatCount = numberOfRotation;
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
    
    [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

No comments:

Post a Comment