IOS animation effect

Source: Internet
Author: User

IOS animation effect

Most common Animation:
// Start the animation
[UIView beginAnimations: nil context: nil];
// Set the animation duration
[UIView setAnimationDuration: 2];
// Animation content
Frame. origin. x + = 150;
[Img setFrame: frame];
// Animation ends
[UIView commitAnimations];

Continuous Animation: displays a series of images one by one
NSArray * myImages = [NSArray arrayWithObjects:
[UIImage imageNamed: @myImage1.png],
[UIImage imageNamed: @myImage2.png],
[UIImage imageNamed: @myImage3.png],
[UIImage imageNamed: @myImage4.gif], nil];

UIImageView * myAnimatedView = [UIImageView alloc];
[MyAnimatedView initWithFrame: [self bounds];
MyAnimatedView. animationImages = myImages; // The animationImages attribute returns an array of animation images.
MyAnimatedView. animationDuration = 0.25; // time used to browse the entire image
MyAnimatedView. animationRepeatCount = 0; // 0 = number of times the loops forever animation is repeated
[MyAnimatedView startAnimating];
[Self addSubview: myAnimatedView];
[MyAnimatedView release];

CATransition Public API Animation:
CATransition * animation = [CATransition animation];
// Animation time
Animation. duration = 0.5f;
// Slow down first and then fast
Animation. timingFunction = UIViewAnimationCurveEaseInOut;
Animation. fillMode = kCAFillModeForwards;
// Animation. removedOnCompletion = NO;

// Various animation Effects
/*
KCATransitionFade;
KCATransitionMoveIn;
KCATransitionPush; z
KCATransitionReveal;
*/
/*
KCATransitionFromRight;
KCATransitionFromLeft;
KCATransitionFromTop;
KCATransitionFromBottom;
*/
// Various combinations
Animation. type = kCATransitionPush;
Animation. subtype = kCATransitionFromRight;

[Self. view. layer addAnimation: animation forKey: @ animation];

CATransition Private API Animation:
Animation. type can be set to the following effect:
Animation effect summary:
/*
SuckEffect (triangle)

RippleEffect)

PageCurl)

PageUnCurl (Flip-down)

OglFlip (up/down flip)

CameraIris/cameraIrisHollowOpen/cameraIrisHollowClose

The following is a blacklist:

SpewEffect: the new layout is released in the middle of the screen to overwrite the old layout.

-GenieEffect: the old version is sucked out at the lower left or lower right of the screen to display the new layout (Aladdin lamp God?) below ?).

-UnGenieEffect: the new layout is released in the lower left or lower right corner of the screen to overwrite the old layout.

-Twist: the layout is transferred horizontally like a tornado.

-Tubey: the layout is vertically attached with an elastic transfer.

-Swirl: the old version rotates at 360 degrees and fades out to display a new layout.

-CharminUltra: the old version fades out and displays the new layout.

-ZoomyIn: the new layout goes from small to front, and the old version disappears from front to front.

-ZoomyOut: zoomyOut appears outside the screen of the new layout, and the earlier version disappears.

-OglApplicationSuspend: the effect of pressing the home button.
*/

UIView Animation:
[UIView beginAnimations: @ animationID context: nil];
[UIView setAnimationDuration: 0.5f];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses: NO];
// The following four effects
/*
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: self. view cache: YES]; // oglFlip, fromLeft
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: self. view cache: YES]; // oglFlip, fromRight
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView: self. view cache: YES];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlDown forView: self. view cache: YES];
*/

[Self. view exchangeSubviewAtIndex: 1 withSubviewAtIndex: 0];
[UIView commitAnimations];
New IOS4.0 method:
Method: + (void) animateWithDuration :( NSTimeInterval) duration animations :( void (^) (void) animations;
+ (Void) animateWithDuration :( NSTimeInterval) duration animations :( void (^) (void) animations completion :( void (^) (BOOL finished) completion; // operations that can be performed after an animation ends.
// Below is the nested animation effect, which increases first and then disappears.
[UIView animateWithDuration: 1.25 animations: ^ {
CGAffineTransform newTransform = CGAffineTransformMakeScale (1.2, 1.2 );
[FirstImageView setTransform: newTransform];
[SecondImageView setTransform: newTransform];}
Completion: ^ (BOOL finished ){
[UIView animateWithDuration: 1.2 animations: ^ {
[FirstImageView setAlpha: 0];
[SecondImageView setAlpha: 0];} completion: ^ (BOOL finished ){
[FirstImageView removeFromSuperview];
[SecondImageView removeFromSuperview];}];
}];

 

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.