UIViewController

public extension UIViewController
extension UIViewController: AlertViewPresenter
  • Loads the childViewController into the specified containerView.

    It can be done after self’s view is initialized, as it uses constraints to determine the childViewController size. Take into account that self will retain the childViewController, so if for any other reason the childViewController is retained in another place, this would lead to a memory leak. In that case, one should call unloadViewController().

    Declaration

    Swift

    func load(childViewController: UIViewController,
              into containerView: UIView,
              with insets: UIEdgeInsets = .zero,
              in viewPositioning: ViewPositioning = .front,
              layout: LayoutMode = .constraints,
              respectSafeArea: Bool = false)

    Parameters

    childViewController

    The controller to load.

    into

    The containerView into which the controller will be loaded.

    viewPositioning

    Back or Front. Default: Front

  • Unloads a childViewController and its view from its parentViewController.

    Declaration

    Swift

    func unloadFromParentViewController()
  • Unloads all childViewController and their view from self.

    Declaration

    Swift

    func unloadChildViewControllers()

Navigation Bar

  • Configures the navigation bar to have a particular image as back button.

    Warning

    This function must be called when self is inside a navigation controller. If not it will arise a runtime fatal error.

    Declaration

    Swift

    func setNavigationBarBackButton(_ image: UIImage)

    Parameters

    image

    The image of the back button.

  • Configures the navigation bar color.

    Warning

    This function must be called when self is inside a navigation controller. If not it will arise a runtime fatal error.

    Declaration

    Swift

    func setNavigationBarColor(_ color: UIColor)

    Parameters

    color

    The new color of the navigation bar. This represents the navigation bar background color.

  • Configures the navigation bar tint color.

    Warning

    This function must be called when self is inside a navigation controller. If not it will arise a runtime fatal error.

    Declaration

    Swift

    func setNavigationBarTintColor(_ color: UIColor)

    Parameters

    color

    The new tint color of the navigation bar. This represents the color of the left and right button items.

  • Configures the navigation bar style.

    Warning

    This function must be called when self is inside a navigation controller. If not it will arise a runtime fatal error.

    Declaration

    Swift

    func setNavigationBarStyle(_ style: UIBarStyle)

    Parameters

    style

    The new style of the navigation bar.

  • Sets a collection of buttons as the navigation bar left buttons.

    Declaration

    Swift

    func setNavigationLeftButtons(_ buttons: [UIBarButtonItem])

    Parameters

    buttons

    the Array of buttons to use.

  • Sets a collection of buttons as the navigation bar right buttons.

    Declaration

    Swift

    func setNavigationRightButtons(_ buttons: [UIBarButtonItem])

    Parameters

    buttons

    the Array of buttons to use.

  • Adds and configures a label to use as title of the navigation bar.

    Declaration

    Swift

    func setNavigationBarTitle(_ title: String, font: UIFont, color: UIColor)

    Parameters

    title

    the string of the label.

    font

    the font to use for the label.

    color

    the color of the text.

  • Adds an ImageView with the image passed as the titleView of the navigation bar.

    Declaration

    Swift

    func setNavigationBarTitleImage(_ image: UIImage)

    Parameters

    image

    The image to set as title.

  • Presents a new alert. The alert’s information is stored in the ErrorAlertViewModel passed by parameter.

    Warning

    The closure is fired when the alert is shown, it is not related to the dismiss/confirmation. Dismiss and confirmation callbacks can be set on the ErrorAlertViewModel.

    Declaration

    Swift

    public func presentAlert(_ alertViewModel: ErrorAlertViewModel, completion: (() -> Void)? = .none)

    Parameters

    alertViewModel

    ErrorAlertViewModel.

    completion

    Closure that fires when the alert is shown.

  • Presents a new alert. The alert’s information is stored in the ConfirmationAlertViewModel passed by parameter.

    Warning

    The closure is fired when the alert is shown, it is not related to the dismiss/confirmation. Dismiss and confirmation callbacks can be set on the ConfirmationAlertViewModel.

    Declaration

    Swift

    public func presentAlert(_ alertViewModel: ConfirmationAlertViewModel, completion: (() -> Void)? = .none)

    Parameters

    alertViewModel

    ConfirmationAlertViewModel.

    completion

    Closure that fires when the alert is shown.