UIViewController
extension UIViewController
-
Wraps the receiving view controller in a navigation controller. The receiver is set as the
rootViewControllerof the navigation controller.Declaration
Swift
@discardableResult public func withNavigation() -> UINavigationControllerReturn Value
The navigation controller that contains the receiver as the
rootViewController. -
Applies the specified modal presentation style to the view controller.
Declaration
Swift
@discardableResult public func withPresentation(_ presentation: UIModalPresentationStyle) -> SelfParameters
presentationA modal presentation style.
Return Value
The view controller after applying the style.
-
Applies the specified modal transition style to the view controller.
Declaration
Swift
@discardableResult public func withTransition(_ transition: UIModalTransitionStyle) -> SelfParameters
transitionA modal transition style.
Return Value
The view controller after applying the style.
-
Applies the specified navigation style to the view controller.
Note
If
navigationStyleis.withNavigation, then calling this method is equivalent to callingwithNavigation(). IfnavigationStyleis.none, then calling this method does nothing.Declaration
Swift
@discardableResult public func withNavigationStyle(_ navigationStyle: NavigationStyle) -> UIViewControllerParameters
navigationStyleA navigation style.
Return Value
The view controller after applying the style.
-
Applies the specified navigation style to the view controller.
Declaration
Swift
@discardableResult public func withStyles(navigation: NavigationStyle, presentation: UIModalPresentationStyle, transition: UIModalTransitionStyle) -> UIViewControllerParameters
navigationA navigation style.
presentationA modal presentation style.
transitionA modal transition style.
Return Value
The view controller after applying the style.
-
Presents a view controller using the specified presentation type.
Warning
The
completionparameter is ignored forshowandshowDetailpresentation types.Declaration
Swift
public func presentController(_ controller: UIViewController, type: PresentationType, animated: Bool = true, completion: (() -> Void)? = nil)Parameters
viewControllerThe view controller to display over the current view controller.
typeThe presentation type to use.
animatedPass
trueto animate the presentation,falseotherwise.completionThe closure to be called.
-
Dismisses the receiving view controller.
Declaration
Swift
public func dismissController(animated: Bool = true, completion: (() -> Void)? = nil)Parameters
animatedPass
trueto animate the presentation,falseotherwise.completionThe closure to be called upon completion.
-
Adds a dismiss button having the provided configuration, if needed.
Note
This method does nothing if the view controller is not presented modally.
Declaration
Swift
public func addDismissButtonIfNeeded(config: DismissButtonConfig = DismissButtonConfig())Parameters
configThe configuration to apply to the dismiss button.
-
Adds a dismiss button having the provided configuration.
Note
The view controller must have a non-nil
navigationItem.Declaration
Swift
public func addDismissButton(config: DismissButtonConfig = DismissButtonConfig())Parameters
configThe configuration to apply to the dismiss button.
View on GitHub
UIViewController Extension Reference