UIViewController

public extension UIViewController

ViewController+ActionSheet is used to present an action sheet.

Author

Adamas

Version

1.9.15

Date

28/03/2023
  • Show an action sheet

    Declaration

    Swift

    func showActionSheet(from view: UIView,
                         withTitle title: String?,
                         message: String?,
                         and items: [ActionSheetItem],
                         under interfaceIdiom: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom)

    Parameters

    title

    The title of the action sheet

    message

    The message of the action sheet

    items

    A list of actions

    view

    The view that calls this action sheet. An arrow will be pointed to the center of this view on iPad.

    interfaceIdom

    The interface idom of the device.

  • Whether the view controller is a root view controller or not.

    Declaration

    Swift

    var isRootViewController: Bool { get }
  • The completion block won’t be called if the actual action is popping a view controller

    Declaration

    Swift

    func back(withAnimation shouldAnimate: Bool = true,
              completion: @escaping () -> Void = {})

    Parameters

    shouldAnimate

    Whether or not there should be a back animation.

    completion

    Completion block after finishing the transaction

  • Setup the back button

    Declaration

    Swift

    func setupBackButton(withBackTitle backTitle: String? = nil,
                         withBackImage backImage: UIImage? = nil,
                         withCancelTitle cancelTitle: String? = nil,
                         withCancelImage cancelImage: UIImage? = nil)

    Parameters

    backTitle

    The title of the back button if there is a previous view controller.

    backImage

    The image of the back button if there is a previous view controller.

    cancelTitle

    The title of the cancel button if the current view controller is the root view controller.

    cancelImage

    The image of the cancel button if the current view controller is the root view controller.

  • Perform the back action

    Declaration

    Swift

    @objc
    func backAction()
  • The top view controller from the current view.

    Declaration

    Swift

    var topViewController: UIViewController? { get }