IOS 7 Custom Animation jump

Source: Internet
Author: User

Introduction

In the iOS7 system, if you use text messages or appStore's native tool, you will find such a detail. The Push in UINavigationViewController is no longer the Left shift of the old interface like iOS6, but the new interface slides directly to the right. Instead, the new view slides in from the right and is built on the previous view controller, you can also use gestures to slide the left border of the interface to jump to the previous interface. 1.1, 1.2.


Figure 1.1 Figure 1.2

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + primary + rb + 0 s/bBvbf5zbzWrrzktcTH + primary/vPorjmy9 + primary/nT0LrN1eLR + primary/secondary/primary + tbHE47Xju/primary/hidden + 7rb /kernel + kernel/LqstcS0 + sLrysfL + dKq1rTQ0LXEtq + 7 raOsy/kernel + kernel/2 NbGxvfHsKOszqrL/Mno1sPM + kernel/LXEtq + kernel/kernel + Kernel + examples/Wy/examples/W0ru49ravu62/2NbGxvehozwvcD4KPHA + Signature = "left"> Create a new object that inherits from NSObject and follows the UIViewControllerAnimatedTransitioning

Protocol class. The UIViewControllerAnimatedTransitioning protocol must implement two methods to define custom animations between view controllers.

@ Interface CustomPresentAnimationController: NSObject

@ End

Add the following two methods to the. m file:

1. Control the execution time of the entire jump animation. The execution time in the example code is set to two seconds.

-(NSTimeInterval) transitionDuration:
(Id ) TransitionContext {

Return2.0;

}

2. The method parameter transitionContext can help you successfully obtain the View Controller, content view, and a few other ins and outs before and after the jump. You can traverse these attributes and rely on the included View Controller to make your jump animation different.

-(Void) animateTransition:
(Id ) TransitionContext {

// 1. obtain state from the context

UIViewController * toViewController = [transitionContext viewControllerForKey: UITransitionContextToViewControllerKey];

CGRectfinalFrame = [transitionContext finalFrameForViewController: toViewController];

// 2. obtain the container view

UIView * containerView = [transitionContext containerView];

// 3. set initial state

CGRectscreenBounds = [[UIScreenmainScreen] bounds]; toViewController. view. frame =

CGRectOffset (finalFrame, 0, screenBounds. size. height); // 4. add the view

[ContainerViewaddSubview: toViewController. view];

// 5. animate

NSTimeIntervalduration =
[Self transitionDuration: transitionContext];

[UIViewanimateWithDuration: duration animations: ^ {

ToViewController. view. frame = finalFrame;} completion: ^ (BOOLfinished ){

// 6. inform the context of completion

[TransitionContext completeTransition: YES];

}];

}

Click "Follow me" to learn more !!!

GROUP: 336146073

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.