@available(iOS 9.0, *) public class Navigate
public init(controller: UINavigationController? = nil)
var shared: Navigate
Configure the Navigate Singleton with the Root Navigation Controller
@discardableResult public func configure(controller: UINavigationController?) -> Self
Set the visibleViewController's title
@discardableResult public func set(title: String) -> Self
- title: The title of the currentViewController
Set the left barButton
@discardableResult public func setLeft(barButton: UIBarButtonItem?, animated: Bool = true) -> Self
- barButton: The UIBarButtonItem to be set
- animated: Should animate setting the left UIBarButtonItem
Set the right barButton
@discardableResult public func setRight(barButton: UIBarButtonItem?, animated: Bool = true) -> Self
- barButton: The UIBarButtonItem to be set
- animated: Should animate setting the right UIBarButtonItem
Set the left barButtons
@discardableResult public func setLeft(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self
- barButton: The [UIBarButtonItem] to be set
- animated: Should animate setting the left [UIBarButtonItem]
Set the right barButtons
@discardableResult public func setRight(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self
- barButton: The [UIBarButtonItem] to be set
- animated: Should animate setting the right [UIBarButtonItem]
Go to a viewController by using the configured NavigationController
public func go(_ viewController: UIViewController, style: NavigationStyle, completion: (() -> Void)? = nil)
- viewController: UIViewController to navigate to
- style: Style of navigation
Go to a viewController by using another viewController
public func go(from: UIViewController, to: UIViewController, style: NavigationStyle, completion: (() -> Void)? = nil)
- from: The UIViewController that is handling the navigation
- viewController: UIViewController to navigate to
- style: Style of navigation
Navigate back and dismiss the visibleViewController
public func back(toRoot: Bool = false)
- toRoot: Should navigate back to the rootViewController
Dismiss the visibleViewController
public func dismiss()
Show an Alert
public func alert(title: String, message: String, withActions actions: [UIAlertAction] = [], secondsToPersist: Double?, _ closure: ((UIAlertController) -> Void)? = nil)
- title: Title of the UIAlertController
- message: Message of the UIAlertController
- withactions: Array of action objects to be added to the Alert
- secondsToPersist: Amount of seconds the Alert should show before dismissing itself
- closure: A closure that is passed the UIAlertController before presenting it
Show an ActionSheet
public func actionSheet(title: String, message: String, withActions actions: [UIAlertAction] = [], _ closure: ((UIAlertController) -> Void)? = nil)
- title: Title of the UIAlertController
- message: Message of the UIAlertController
- withactions: Array of action objects to be added to the ActionSheet
- closure: A closure that is passed the UIAlertController before presenting it
toast(style:pinToTop:secondsToPersist:animationInDuration:animationOutDuration:padding:tapHandler:_:)
Show a Toast Message
@available(iOS 11.0, *) public func toast(style: ToastStyle = .custom, pinToTop: Bool = true, secondsToPersist: Double? = nil, animationInDuration: Double = 0.5, animationOutDuration: Double = 0.5, padding: Float = 8, tapHandler: @escaping (UIView) -> Void = { $0.removeFromSuperview() }, _ closure: @escaping () -> UIView)
- style: The ToastStyle (default: .custom)
- pinToTop: Should the Toast pin to the top or bottom (default: true)
- secondsToPersist: Amount of seconds the Toast should show before dismissing itself
- animationInDuration: The amount of seconds the Toast should fade in (default: 0.5)
- animationOutDuration: The amount of seconds the Toast should fade out (default: 0.5)
- padding: The amount of spacing around the Toast
- tapHandler: What happens when the user taps on the Toast (default: { $0.removeFromSuperview() })
- closure: A trailing closure that accepts a view
Destory the toast
public func destroyToast()