Rotation of the animation view in IOS development (90)

Source: Internet
Author: User

1 Preface
Today, we will learn how to create a rotating affine transform and use the UIView animation method to perform the rotating action.


2. code example
ZYViewController. m

 

[Plain]
-(Void) viewDidLoad
{
[Super viewDidLoad];
UIImage * xcodeImage = [UIImage imageNamed: @ "Xcode.png"];
Self. xcodeImageView = [[UIImageView alloc] initWithImage: xcodeImage];
// Set the Frame of the image
[Self. xcodeImageView setFrame: CGRectMake (0.0f, 0.0f, 100366f, 100366f)];
Self. view. backgroundColor = [UIColor whiteColor];
[Self. view addSubview: self. xcodeImageView];
}
 
-(Void) viewDidAppear :( BOOL) paramAnimated {[super viewDidAppear: paramAnimated];
Self. xcodeImageView. center = self. view. center;
/* Begin the animation */
[UIView beginAnimations: @ "clockwiseAnimation" context: NULL];
/* Make the animation 5 seconds long */
[UIView setAnimationDuration: 5.0f];
[UIView setAnimationDelegate: self];
// Call the clockwiseRotationStopped method when the animation is stopped.
[UIView setAnimationDidStopSelector: @ selector (clockwiseRotationStopped: finished: context :)];
// Rotate 90 degrees clockwise
Self. xcodeImageView. transform = CGAffineTransformMakeRotation (90.0f * M_PI)/180.0f );
/* Commit the animation */
[UIView commitAnimations];
}
 
-(Void) clockwiseRotationStopped :( NSString *) paramAnimationID finished :( NSNumber *) paramFinished
Context :( void *) paramContext {
[UIView beginAnimations: @ "counterclockwiseAnimation" context: NULL];
/* 5 seconds long */
[UIView setAnimationDuration: 5.0f];
/* Return to the original rotation */
Self. xcodeImageView. transform = CGAffineTransformIdentity;
[UIView commitAnimations];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.