Several methods of animation programming in iOS development and ios development

Source: Internet
Author: User

Several methods of animation programming in iOS development and ios development
Several methods of animation programming in iOS development

There are five animation summaries in IOS: UIView <block>, CAAnimation <CABasicAnimation, CATransition, CAKeyframeAnimation>, NSTimer

Here I will summarize these five methods. In fact, animation programming in iOS development will change here, so it is not difficult to understand these animation programming.

 

I. general way of UIView Animation
  • Typedef enum {
  • UIViewAnimationTransitionNone, // normal status
  • UIViewAnimationTransitionFlipFromLeft, // flip from left to right
  • UIViewAnimationTransitionFlipFromRight, // flip from right to left
  • UIViewAnimationTransitionCurlUp, // flip up
  • UIViewAnimationTransitionCurlDown, // flip down
  • } UIViewAnimationTransition;
  • Typedef enum {
  • UIViewAnimationCurveEaseInOut,
  • UIViewAnimationCurveEaseIn,
  • UIViewAnimationCurveEaseOut,
  • UIViewAnimationCurveLinear
  • } UIViewAnimationCurve;
Here I have implemented a Custom Animation Method for ease of use. You only need to call it to implement good functions.

 

Method implementation

-(Void) UIViewAnimation :( UIView *) view frame :( CGRect) frame type :( int) type alpha :( float) alpha duration :( float) duration

{

// Implement the corresponding parameters in the method. When calling this method, you only need to enter the required parameters in the method to call this method well and implement the desired function!

[UIView beginAnimations: nil context: nil];

[UIView setAnimationDuration: duration];

[UIView setAnimationCurve: type];

[UIView setAnimationDelegate: self];

View. alpha = alpha;

View. frame = frame;

[UIView commitAnimations];

}

Call Method

[Self UIViewAnimation: downView frame: CGRectMake (0, height, 320, 58) type: UIViewAnimationCurveEaseOut alpha: 1 duration: 0.3];

 

Block Method

 

More advanced block animation (Next) embedded

-(Void) changeUIView {[UIView animateWithDuration: 2 delay: 0 options: UIViewAnimationOptionCurveEaseOut animations: ^ (void) {moveView. alpha = 0.0;} completion: ^ (BOOL finished) {[UIView animateWithDuration: 1 delay: 1.0 options: available | refreshing animations: ^ (void) {[UIView setAnimationRepeatCount: 2.5]; moveView. alpha = 1.0 ;}completion: ^ (BOOL finished) {}] ;}];}

 

Ii. CAAnimation

You need to add libraries and header files.

Caanimation has multiple subclasses

CABasicAnimation

 

CAKeyframeAnimation

 

CATransition
  • /*
  • KCATransitionFade;
  • KCATransitionMoveIn;
  • KCATransitionPush;
  • KCATransitionReveal;
  • */
  • /*
  • KCATransitionFromRight;
  • KCATransitionFromLeft;
  • KCATransitionFromTop;
  • KCATransitionFromBottom;
  • */
  • /*
  • Cube
  • SuckEffect
  • OglFlip flip
  • RippleEffect
  • PageCurl Paging
  • PageUnCurl
  • CameraIrisHollowOpen
  • CameraIrisHollowClose
  • */

 

Iii. NSTimer

This is a timer to operate the animation, he can combine the above method to achieve the diversity of 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.