Use UIPresentationController in ios8.
1. Introduction to UIPresentationController
UIPresentationController is an API added to ios8. it is used to control Jump effects between controllers. For example, if you want to implement a special effect and display a window, the size and position are customized, And the mask is on the original page. Previously, you can operate some methods of view to implement it.
2. Introduction
1. Set the forwarding proxy and display method of the Target Controller
Controller. modalPresentationStyle = UIModalPresentationStyle. Custom // set the animation style controller. transitioningDelegate = transtinoDelegate // This object must implement the UIViewControllerTransitioningDelegate Protocol
2. transtionDelegate implements the UIViewControllerTransitioningDelegate protocol Method
// Return to the control controller. The animation object optional func animationControllerForPresentedController (presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) is displayed? // Returns the optional func animationControllerForDismissedController (dismissed: UIViewController)-> UIViewControllerAnimatedTransitioning? @ Availability (iOS, introduced = 8.0) // returns the optional func presentationControllerForPresentedViewController (presented: UIViewController, presentingViewController presenting: UIViewController !, SourceViewController source: UIViewController)-> UIPresentationController?
3. Control the jump class of the Controller
The class that controls controller redirection inherits from UIPresentationController
/* Constructor: parameter: the original controller */init (presentedViewController: UIViewController !, PresentingViewController: UIViewController !)
Common attributes and Methods
PresentedViewController: View Controller presentingViewController to be displayed by modal: View Controller containerView () Container view presentedView () func presentationTransitionWillBegin () Jump to func prepare (completed: Bool) jump to func dismissalTransitionWillBegin () dismiss: func dismissalTransitionDidEnd (completed: Bool) dismiss to complete func frameOfPresentedViewInContainerView () Target Controller settings
4. Control Animation
The control animation class inherits from UIViewControllerAnimatedTransitioning.
// Animation execution time func transitionDuration (transitionContext: UIViewControllerContextTransitioning)-> NSTimeInterval // func animateTransition (transitionContext: UIViewControllerContextTransitioning)
5. Summary
1. Set the forwarding proxy of the Target Controller
2. The session proxy returns three objects to control the transfer process.
3. Control the Controller transfer object. You can perform operations before and after the session, such as adding a mask.
4. Control the transfer animation, used to set the animation that the target controller appears or disappears, and the size and style of the controller.
3. API details
Wait...
4. Custom jump Demo
Wait...