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