UIAlertAction

public extension UIAlertAction

The UIAlertAction extension

  • The default cancel button label

    Declaration

    Swift

    static let cancel: String
  • The default retry button label

    Declaration

    Swift

    static let retry: String
  • The default close button label

    Declaration

    Swift

    static let close: String
  • The default remove button label

    Declaration

    Swift

    static let remove: String
  • Initialize a cancel alert action

    Declaration

    Swift

    static func cancel(_ handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction

    Parameters

    handler

    if provided, will be invoked after the cancel button is clicked

    Return Value

    a cancel alert action

  • Initialize a cancel alert action with pop back functionality

    Declaration

    Swift

    static func cancel(_ viewController: UIViewController) -> UIAlertAction

    Parameters

    viewController

    a view needs to show the alert dialog

    Return Value

    a cancel alert action with a pop back handler

  • Initialize a close alert action

    Declaration

    Swift

    static func close(_ handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction

    Parameters

    handler

    if provided, will be invoked after the close button is clicked

    Return Value

    a close alert action

  • Initialize a close alert action with pop back functionality

    Declaration

    Swift

    static func close(_ viewController: UIViewController) -> UIAlertAction

    Parameters

    viewController

    a view needs to show the alert dialog

    Return Value

    a close alert action with a pop back handler

  • Initialize a remove alert action

    Declaration

    Swift

    static func remove(_ handler: @escaping (UIAlertAction) -> Void,
                       _ title: String = UIAlertAction.remove) -> UIAlertAction

    Parameters

    handler

    will be invoked after the remove button is clicked

    title

    a string value of the alert action

    Return Value

    a remove alert action

  • Initialize a retry alert action

    Declaration

    Swift

    static func retry(_ handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction

    Parameters

    handler

    if provided, will be invoked after the retry button is clicked

    Return Value

    a confirm retry action

  • Add an icon image on this alert action

    Declaration

    Swift

    func addIcon(imageName: String) -> UIAlertAction

    Parameters

    imageName

    The image name

    Return Value

    An alert action with an icon