UIViewController
extension UIViewController
-
Wraps the receiving view controller in a navigation controller. The receiver is set as the
rootViewController
of the navigation controller.Declaration
Swift
@discardableResult public func withNavigation() -> UINavigationController
Return 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) -> Self
Parameters
presentation
A 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) -> Self
Parameters
transition
A modal transition style.
Return Value
The view controller after applying the style.
-
Applies the specified navigation style to the view controller.
Note
If
navigationStyle
is.withNavigation
, then calling this method is equivalent to callingwithNavigation()
. IfnavigationStyle
is.none
, then calling this method does nothing.Declaration
Swift
@discardableResult public func withNavigationStyle(_ navigationStyle: NavigationStyle) -> UIViewController
Parameters
navigationStyle
A 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) -> UIViewController
Parameters
navigation
A navigation style.
presentation
A modal presentation style.
transition
A modal transition style.
Return Value
The view controller after applying the style.
-
Presents a view controller using the specified presentation type.
Warning
The
completion
parameter is ignored forshow
andshowDetail
presentation types.Declaration
Swift
public func presentController(_ controller: UIViewController, type: PresentationType, animated: Bool = true, completion: (() -> Void)? = nil)
Parameters
viewController
The view controller to display over the current view controller.
type
The presentation type to use.
animated
Pass
true
to animate the presentation,false
otherwise.completion
The closure to be called.
-
Dismisses the receiving view controller.
Declaration
Swift
public func dismissController(animated: Bool = true, completion: (() -> Void)? = nil)
Parameters
animated
Pass
true
to animate the presentation,false
otherwise.completion
The 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
config
The 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
config
The configuration to apply to the dismiss button.