DeckTransitioningDelegate
public final class DeckTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate
The DeckTransitioningDelegate class vends out the presentation and animation controllers required to present a view controller with the Deck transition style
The following snippet described the steps for presenting a given
ModalViewController
with the DeckTransitioningDelegate
let modal = ModalViewController()
let transitionDelegate = DeckTransitioningDelegate()
modal.transitioningDelegate = transitionDelegate
modal.modalPresentationStyle = .custom
present(modal, animated: true, completion: nil)
-
init(isSwipeToDismissEnabled:presentDuration:presentAnimation:presentCompletion:dismissDuration:dismissAnimation:dismissCompletion:)
Returns a transitioning delegate to perform a Deck transition. All parameters are optional. Swipe-to-dimiss is enabled by default. Leaving the duration parameters empty gives you animations with the default durations (0.3s for both)
Declaration
Swift
@objc public init(isSwipeToDismissEnabled: Bool = true, presentDuration: NSNumber? = nil, presentAnimation: (() -> ())? = nil, presentCompletion: ((Bool) -> ())? = nil, dismissDuration: NSNumber? = nil, dismissAnimation: (() -> ())? = nil, dismissCompletion: ((Bool) -> ())? = nil)
Parameters
isSwipeToDismissEnabled
Whether the modal view controller should be dismissed with a swipe gesture from top to bottom
presentDuration
The duration for the presentation animation
presentAnimation
An animation block that will be performed alongside the card presentation animation
presentCompletion
A block that will be run after the card has been presented
dismissDuration
The duration for the dismissal animation
dismissAnimation
An animation block that will be performed alongside the card dismissal animation
dismissCompletion
A block that will be run after the card has been dismissed
-
Returns an animation controller that animates the modal presentation
This is internal infrastructure handled entirely by UIKit and shouldn’t be called directly
Declaration
Swift
public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning?
Parameters
presented
The modal view controller to be presented onscreen
presenting
The view controller that will be presenting the modal
source
The view controller whose
present
method is calledReturn Value
An animation controller that animates the modal presentation
-
Returns an animation controller that animates the modal dismissal
This is internal infrastructure handled entirely by UIKit and shouldn’t be called directly
Declaration
Swift
public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
Parameters
dismissed
The modal view controller which will be dismissed
Return Value
An animation controller that animates the modal dismisall
-
Returns a presentation controller that manages the modal presentation
This is internal infrastructure handled entirely by UIKit and shouldn’t be called directly
Declaration
Swift
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?
Parameters
presented
The modal view controller
presenting
The view controller which presented the modal
source
The view controller whose
present
method was called to present the modalReturn Value
A presentation controller that manages the modal presentation