Learn IOS animation effects and enable Redirect on viewcontroller

Source: Internet
Author: User
Tags uikit

 

Animation effects provide a smooth user experience during status or page conversion. In iOS, we do not need to write the animation code by ourselves, core animation provides a variety of APIs to achieve the animation effect you need. Uikit only uses uiview to display animations.

Animation effects provide a smooth user experience during status or page conversion. In iOS, we do not need to write the animation code by ourselves, core animation provides a variety of APIs to achieve the animation effect you need.
Uikit only uses uiview to display animations. animations support these attribute changes under uiview:

Frame

Bounds

Center

Transform

Alpha

Backgroundcolor

Contentstretch

1. Use uiview animation in commitanimations Mode

// Display the transition animation effect when you touch the screen-(void) touchesended :( nsset *) touches withevent :( uievent *) event {// If the animation is not runable, if (! [Uiview areanimationsenabled]) {[self. nextresponder touchesended: touches withevent: event]; return;} // static uiviewanimationtransition transition = transition; uiview * nextview = [self nextview]; // create the next image (uiview) [uiview beginanimations: Nil context: NULL]; [uiview setanimationdelegate: Self]; [uiview progress: @ selector (animationdidstop)]; [uiview setanimationduration: 2.0]; [uiview setanimationtransition: Transition forview: Self. view cache: Yes]; [[self. view viewwithtag: ktagviewfortransitiontest] removefromsuperview]; [self. view addsubview: nextview]; [uiview commitanimations]; // temporarily set the screen to invalid [uiview setanimationsenabled: No]; // switch the transition animation effect if (uiviewanimationtransitioncurldown <++ transition) {transition = uiviewanimationtransitionflipfromleft ;}}

The following figure shows the effect after clicking change.


1.2 switch the two view locations in the current view Controller
[Self. View exchangesubviewatindex: 1 withsubviewatindex: 0];
Add two views, one redview and one yellowview.

1.3
, [Uiview setanimationdidstopselector: @ selector (animationfinish :)];
Before the commitanimations message, you can set the callback after the animation is completed:
[Uiview setanimationdidstopselector: @ selector (animationfinish :)];


2. Use: catransition
Jump between two viewcontrollers

Note:: Make sure to add quartzcore. Framework
To the project, you also need to Baotou the file

# Import <quartzcore/quartzcore. h>

Class class = nsclassfromstring ([items _ objectatindex: indexpath. row]); Id viewcontroller = [[class alloc] init] autorelease]; If (viewcontroller) {catransition * transition = [catransition animation]; transition. duration = 1.0f; transition. type = @ "cube"; // cube effect transition. subtype = kcatransitionfromleft; [self. navigationcontroller pushviewcontroller: viewcontroller animated: Yes]; [self. navigationcontroller. view. layer addanimation: Transition forkey: @ "Animation"];}

The transition. Type type can be
Fade, push, uncover, and cover
Nsstring * const kcatransitionfade;
Nsstring * const kcatransitionmovein;
Nsstring * const kcatransitionpush;
Nsstring * const kcatransitionreveal;

These four types,
Transition. Subtype
There are also four types
Nsstring * const kcatransitionfromright;
Nsstring * const kcatransitionfromleft;
Nsstring * const kcatransitionfromtop;
Nsstring * const kcatransitionfrombottom;

2.2 Private animation types:
Cube, absorption, flip, ripple, flip, on-camera, and off-camera.

2.3 startprogress endprogress attribute of catransition
These two attributes are of the float type.
You can control the animation process and place the animation on a certain animation point. The value ranges from 0.0 to 1.0. Endprogress must be greater than or equal to startprogress.
For example, if the above cube is switched to, you can set endprogress = 0.5 to let the animation stay in the normal rotation position.
The above private animation effects should be used with caution in practical applications. This is because the App Store may reject these animation effects during review.


3. + (void) animatewithduration of uiview
:( Nstimeinterval) Duration animations :( void (^) (void) animations completion :( void (^) (bool finished) completion
Method.
This method is supported after ios4.0.
It is simpler and easier to use than the uiview method in 1.
Add moveview to didview.


Use the uiview animatewithduration animation to move the animation. After the animation is moved, add a label.
3.2. nested use of animatewithduration
The effect of this nesting is to first change the view to transparent, from transparent to opaque, and repeat 2.5 transparent to opaque.

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.