IOS自帶view動畫效果


1.普通動畫:

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:2];

frame.origin.x += 150;

[img setFrame:frame];

[UIView commitAnimations];

2.連續動畫(一系列圖像):

NSArray *myImages = [NSArray arrayWithObjects:

[UIImage imageNamed:@"myImage1.png"],

[UIImage imageNamed:@"myImage2.png"],

[UIImage imageNamed:@"myImage3.png"],

[UIImage imageNamed:@"myImage4.png"], nil];

UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:[self bounds]];

myAnimatedView.animationImages = myImage;

myAnimatedView.animationRepeatCount = 0;

[myAnimatedView startAnimating];

[self addSubview:myAnimatedView];

[my AnimatedView release];

3.CATransition Public API:

CATransition *animation = [CATransition animation];

animation.duration = 0.5f;

animation.timingFunction = UIViewAnimationCurveEaseInOut;

animation.fillMide = KCAFillModeForwards;

//各種動畫效果

/*

KCATransitionFade;

KCATransitionMoveIn;

KCATransitionPush;

KCATransitionReveal;

*/

/*

KCATransitionFromeRight;

KCATransitionFromLeft;

KCATransitionFormTop;

kCATransitionFromButtons;

*/

//各種組合

animation.type = KCATransitionPush;

animation.subtype = KCATransitionFromRight;

[self.view.layer addAnimation:animation forKey:@"animation"];

4.UIView Animations動畫:

[UIView beginAnimations:@"animationID" context:nil];

[UIView setAnimationDuration:0.5f];

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationRepeatAutoreverses:NO];

//以下四種效果

/*

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormLeft forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormRight forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

*/

5.嵌套使用,先變大再消失

[UIView animateWithDuration:1.25 aniamtions:^{

        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];

                }

                ];

        }

];

----------------------------------

All animation name of LayerKit in iPhone:

oglFlip // flip in Stocks
pageCurl // page animation in Notes
pageUnCurl // reverse of pageCurl
suckEffect      // delete animation in Notes
spewEffect // reverse of suckEffect
genieEffect // minimize effect like in MacOSX
unGenieEffect // reverse of genieEffect
twist           // flip the page in twist style
tubey      // flip the page in tube style
swirl           // swirl effect
rippleEffect // ripple effect
cameraIris       // take photo effect in Camera
cameraIrisHollow // 
cameraIrisHollowOpen // apeature open effect
cameraIrisHollowClose // apeature close effect
charminUltra // wash out and then return to normal
reflection        //
zoomyIn // zoomin, fade in transition
zoomyOut // zoom out, fade in transition
oglApplicationSuspend //quit program zoom out effect
mapCurl // Maps page flip up effect
mapUnCurl // maps page flip down effect

Note that except oglFlip, other transition effect not work under simulator, and simple fade in/out will be used instead. But it actually works on the real device.
聲明:OSCHINA 博客文章版權屬於作者 轉載於ios開發者社區

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM