RNAlertController

@objcMembers
public final class RNAlertController : UIViewController

An object that provides RNAlertController.

Initializer

  • Initializes the alert.

    Declaration

    Swift

    public convenience init(title: String?, message: String?)

    Parameters

    title

    Title for the alert.

    message

    Message body of the alert.

UIViewController Overrides

Static Initializer

  • Initializes the alert.

    Declaration

    Swift

    static func alertController(title: String?, message: String?) -> RNAlertController

    Parameters

    title

    Title for the alert.

    message

    Message body of the alert.

    Return Value

    RNAlertController instance.

Presentation

  • Presents the alert on the specified view controller.

    Use this method to present RNAlertController alert on a specific view controller.

    Declaration

    Swift

    func present(on viewController: UIViewController, completion: (() -> Void)? = nil)

    Parameters

    viewController

    UIViewController where the alert is to be presented.

    completion

    Block to run after presenting the alert.

  • Presents the alert on its own window.

    Declaration

    Swift

    func present(_ completion: (() -> Void)? = nil)

    Parameters

    completion

    Block to run after presenting the alert.

  • Dismisses the alert.

    Declaration

    Swift

    func dismiss(_ completion: (() -> Void)? = nil)

    Parameters

    completion

    Block to run after dismissing the alert.

Alert Components

  • Adds a button to the alert.

    Declaration

    Swift

    @discardableResult
    func addButton(title: String, type: AlertButtonType = .default, action: AlertAction? = nil) -> RNAlertController

    Parameters

    title

    Title for the button.

    type

    Button style for the alert.

    action

    Block to run when the button is pressed (i.e. touchUpInside: action).

    Return Value

    RNAlertController instance.

  • Adds an OK button to the alert.

    Declaration

    Swift

    @discardableResult
    func addOkButton(action: AlertAction? = nil) -> RNAlertController

    Parameters

    action

    Block to run when the button is pressed (i.e. touchUpInside event).

    Return Value

    RNAlertController instance.

  • Adds a Cancel button to the alert.

    Declaration

    Swift

    @discardableResult
    func addCancelButton(action: AlertAction? = nil) -> RNAlertController

    Parameters

    action

    Block to run when the button is pressed (i.e. touchUpInside event).

    Return Value

    RNAlertController instance.

  • Sets attributed text for the message.

    When set, message text will use attributed text instead of regular text.

    Declaration

    Swift

    @discardableResult
    func setAttributedMessageText(_ attributedText: NSAttributedString?) -> RNAlertController

    Parameters

    attributedText

    Attributed string to set.

  • Sets the banner image for the alert.

    Banner image is displayed under the message body or at the very top of the body. Consequent calls of this method will result in replacement of previously set image.

    Declaration

    Swift

    @discardableResult
    func setBannerImage(_ image: UIImage, position: AlertBannerPosition = .afterBody) -> RNAlertController

    Parameters

    image

    image to use in the alert.

    position

    determines the position of the image.

    Return Value

    RNAlertController` instance.

  • Sets picker view data for the alert.

    Note

    Consequent calls of this method will result in replacement of previously set picker data.

    Declaration

    Swift

    @discardableResult
    func setPickerData(items: [String], selectedRow: Int = 0, selectionAction: AlertPickerAction?) -> RNAlertController

    Parameters

    items

    An array of String to represent picker data collection.

    selectedRow

    Row to be selected. The default value is 0 (zero) indicating the first item in the collection.

    selectionAction

    Block to execute when an item is selected.

    Return Value

    RNAlertController instance.

  • Sets a button with an URL.

    A button is placed under the message body. Consequent calls of this method will result in replacement of previously set URL.

    Declaration

    Swift

    @discardableResult
    func setURL(urlString: String, text: String? = nil) -> RNAlertController

    Parameters

    urlString

    String representation of the URL.

    text

    Placeholder for the URL. If nil is passed, original URL will be used.

    Return Value

    RNAlertController instance.

  • Sets a date picker with a selected date.

    A date picker is placed under the message body.

    Declaration

    Swift

    @discardableResult
    func setDatePicker(mode: UIDatePicker.Mode,
                       selectedDate: Date? = nil,
                       maximumDate: Date? = nil,
                       minimumDate: Date? = nil,
                       selectionAction: AlertDatePickerAction? = nil) -> RNAlertController

    Parameters

    mode

    UIDatePicker.Mode describing the mode displayed the date picker.

    selectedDate

    Date to set. If passed nil, current date is used.

    maximumDate

    Maximum date that a date picker can show.

    minimumDate

    Minimum date that a date picker can show.

    selectionAction

    Block to execute when date is selected.

    Return Value

    RNAlertController instance.

  • Sets a checkbox with a title below the message body.

    Declaration

    Swift

    @discardableResult
    func setCheckboxView(title: String?,
                         isSelected: Bool,
                         action: AlertCheckboxAction?) -> RNAlertController

    Parameters

    title

    A message that is shown on the right of the checkbox.

    isSelected

    Boolean value indicating the primary state of the checkbox.

    action

    Block to execute the checkbox is toggled.

    Return Value

    RNAlertController instance.