IOS learning Animation 1: UIKit Animation

Source: Internet
Author: User

IOS learning Animation 1: UIKit Animation
For IOS, you can use the Animation method provided by UIKit for normal animations. For complex animations, you can use Core Animation. 1. Use UIKit animation-(void) animationOfUIKit {UIView * redView = [[UIView alloc] initWithFrame: CGRectMake (10, 10,100,100)]; [self. view addSubview: redView]; // start the animation [UIView beginAnimations: @ "test" context: nil]; // The animation duration [UIView setAnimationDuration: 1]; // set the animation to fade in and out [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];/** place to be animated */redView. backgroundColor = [UIColor blueColor]; redView. frame = CGRectMake (50, 50,200,200); redView. alpha = 0.5; // animation end [UIView commitAnimations];} 2. Use the UIKit animation-(void) animationOfBlock through a code block {// initialize a View, used to display the animated UIView * redView = [[UIView alloc] initWithFrame: CGRectMake (10, 10,100,100)]; [self. view addSubview: redView]; [UIView animateWithDuration: 1 // duration delay: 0 // delay time options: UIViewAnimationOptionTransitionFlipFromLeft // animation effect animations: ^ {// redView of the animation setting area. backgroundColor = [UIColor blueColor]; redView. frame = CGRectMake (50, 50,200,200); redView. alpha = 0.5;} completion: ^ (BOOL finish) {// call at animation end}];} 3. UIView, flip, rotate, offset, flip, zoom, the CGAffineTransform class in the CoreGraphics framework can be used to set the transform attribute of the UIView and control operations such as scaling, rotation, and moving of the view (also called the radiation transformation matrix ), this type of animation performs operations on the starting point of the original view at the original position. After the operation, you can restore the set quantity: view. transform = CGAffineTransformIdentity; flip animation // start animation [UIView beginAnimations: @ "doflip" context: nil]; // set [UIView setAnimationDuration: 1]; // set the animation fade-in and fade-out [UIView setAnimationCurve: complete]; // set the proxy [UIView setAnimationDelegate: self]; // set the flip Direction [UIView setAnimationTransition: Adjust forView: manImageView cache: YES]; // animation end [UIView commitAnimations]; rotate the animation // create a CGAffineTransform transform object CGAffineTransform transform; // set the Rotation Degree transform = CGAffineTransformRotate (manImageView. transform, M_PI/6.0); // The animation starts [UIView beginAnimations: @ "rotate" context: nil]; // The animation often [UIView setAnimationDuration: 2]; // Add the proxy [UIView setAnimationDelegate: self]; // obtain the transform value [manImageView setTransform: transform]; // close the animation [UIView commitAnimations]; offset animation [UIView beginAnimations: @ "move" context: nil]; [UIView setAnimationDuration: 2]; [UIView setAnimationDelegate: self]; // change the manImageView value of x and y of its frame. frame = CGRectMake (100,100,120,100); [UIView commitAnimations]; flip-page animation [UIView beginAnimations: @ "curlUp" context: nil]; // specifies the animation curve type. This enumeration is the default one, linearly consistent [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; // when setting an animation, [UIView setAnimationDuration: 1]; [UIView setAnimationDelegate: self]; // set the page turning direction to [UIView setAnimationTransition: Orientation forView: manImageView cache: YES]; // disable the animation [UIView commitAnimations]; and zoom the animation CGAffineTransform transform = inline (manImageView. transform, 1.2, 1.2); [UIView beginAnimations: @ "scale" context: nil]; [UIView setAnimationDuration: 2]; [UIView setAnimationDelegate: self]; [manImageView setTransform: transform]; [UIView commitAnimations]; the reverse animation effect is based on the current animation. The opposite animation CGAffineTransform transform = CGAffineTransformInvert (manImageView. transform); [UIView beginAnimations: @ "Invert" context: nil]; [UIView setAnimationDuration: 2]; // [UIView setAnimationDelegate: self]; [manImageView setTransform: transform]; // obtain the transform [UIView commitAnimations] of the changed view; // close the animation.

Related Article

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.