Powered By Blogger

Tuesday, May 1, 2012

How to rotate a view in iPhone using QuartzCore.framework?

Hi,
Code regarding the rotation. you can use the below code for simply making rotation to any angle you want. You can also reverse the animation that you want. You need to import "QuartzCore.framework" into your code.

   CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    theAnimation.duration=1.0; // Animation duration
    theAnimation.repeatCount=1; // no of times you want to do animation
    theAnimation.autoreverses=YES; // reverses the animation
    theAnimation.fromValue=[NSNumber numberWithFloat:0.0]; // initial stage of animation
    theAnimation.toValue=[NSNumber numberWithFloat:degreesToRadians(360)]; // rotation angle
    [self.view.layer addAnimation:theAnimation forKey:@"animateRotation"]; // add animation to the
 layer of a view for which you want animation.



If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati
 

No comments:

Post a Comment