New Features of iOS7 ViewController Transition (1) previous summary and key API Introduction
@ Before iOS7, there were four main View Controller switches:
1. Push/Pop, NavigationViewController
2. Present and dismis Modal
3. UITabBarController
4. addChildViewController (generally used for custom container subclass inherited from UIViewController)
IOS5, call-(void) invoke :( UIViewController *) fromViewController toViewController :( UIViewController *) toViewController duration :( NSTimeInterval) duration options :( UIViewAnimationOptions) options animations :( void (^) (void )) animations completion :( void (^) (BOOL finished) completion NS_AVAILABLE_IOS (5_0 );
(1) The first three methods are not mentioned here. It is a common system method. as for the fourth type, I have already elaborated in the previous article-analyzing the effect of Netease tag bar, but the container transition animation provided by it can only implement some simple UIView animations, however, it is difficult to reuse and the coupling is high.
(2) Key APIs:
A. the Animation controller (Animation Controllers) complies with the UIViewControllerAnimatedTransitioning Protocol and is responsible for the actual Animation execution.
B. Interaction Controllers controls interactive transfer by following the UIViewControllerInteractiveTransitioning protocol.
C. Transitioning Delegates provides the required animation controller and interaction controller conveniently based on different transfer types.
Two methods are added to UINavigationControllerDelegate delegate to NavigationController.
UIViewControllerTransitioningDelegate adds transitioningDelegate to the Present and Dismis of Modal.
UITabBarControllerDelegate delegate
-(Id ) TabBarController :( UITabBarController *) tabBarController
InteractionControllerForAnimationController: (id ) AnimationController NS_AVAILABLE_IOS (7_0 );
-(Id ) TabBarController :( UITabBarController *) tabBarController
AnimationControllerForTransitionFromViewController :( UIViewController *) fromVC
ToViewController :( UIViewController *) toVC NS_AVAILABLE_IOS (7_0 );
D. The transfer context (Transitioning Contexts) defines the metadata required for the transfer, such as The View Controller and view attributes involved in the transfer process. The transfer context object complies with the UIViewControllerContextTransitioning protocol, which is generated and provided by the system.
E. Transition Coordinators allows you to run other animations concurrently when running the Transition animation. The transfer Coordinator complies with the UIViewControllerTransitionCoordinator protocol.
(3) The new API mainly provides two VC switching methods:
A. Non-interactive switching means defining an animation effect from one VC to another. It is automatically played during switching,
B. Interactive switching. In this way, you also need to define the animation effect, but the animation effect will be switched to VC Based on the interactive gesture and play the animation effect at the same time. IOS7 provides a default percentage-based animation to implement UIPercentDrivenInteractiveTransition. According to WWDC instructions, the simplest way to implement interactive animation is to inherit UIPercentDrivenInteractiveTransition.