IOS development-custom transfer animation and ios custom transfer Animation
The first is UIPresentationController. This controller provides modal's new viewController with the next step of view and transfer management, from modal viewController to dismiss, UIPresentationController is used to manage all aspects of the View display process. You can add custom animations, respond to changes in the size, and manage how other viewcontrollers are displayed on the screen. During initialization, override initWithPresentedViewController: presentingViewController: This method, initialize and return a presentationController to convert the two views.containerView
This read-only attribute is the view where the rendered view is located. We can add other views to this view by using the insertSubview (dummyView, atIndex: 0) method. Next, we will use two proxies: UIViewControllerTransitioningDelegate and UIViewControllerAnimatedTransitioning to implement the proxy method. isPresented is a flag for rendering.
// Return the Controller object func presentationControllerForPresentedViewController (presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController)-> UIPresentationController? {Return parameters (presentedViewController: presented, presentingViewController: presenting)} // return the func animation (presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {IsPresented = true return self} // returns the func animationControllerForDismissedController (dismissed: UIViewController) object that provides the dismiss animation-> UIViewControllerAnimatedTransitioning? {IsPresented = false return self} // animation duration func transitionDuration (transitionContext: UIViewControllerContextTransitioning ?) -> NSTimeInterval {return 1.2} // transfer animation implementation function func animateTransition (transitionContext: UIViewControllerContextTransitioning ){}
In the last method, the animation process is implemented. In addition, you must set
// Set the transfer animation agent vc. transitioningDelegate = self // set the transfer animation to Custom vc. modalPresentationStyle = UIModalPresentationStyle. Custom
Otherwise, the transition animation cannot be customized.