CreationKit Documentation

Class Modal​Dialog​Action

public final class ModalDialogAction  

An action that can be taken when the user taps a button in a ModalDialog.

You use this class to configure information about a single action, including the title to display in the button, any styling information, and a handler to execute when the user taps the button. After creating an action object, add it to a ModalDialog object before displaying the corresponding dialog to the user.

Nested Types

ModalDialogAction.Style

Styles to apply to action buttons in a dialog.

Initializers

init(title:​image:​right​Image:​style:​object:​handler:​)

public init(title: String, image: UIImage? = nil, rightImage: UIImage? = nil, style: Style, object: Any? = nil, handler: ((ModalDialogAction) -> Void)? = nil)  

Create and return an action with the specified title and behavior.

Actions are enabled by default when you create them.

Parameters

title String

The text to use for the button title.

image UIImage?

The image to place next to the actions title. Images will only be displayed when used in a ModalDialog with the .actionSheet style.

right​Image UIImage?

The image to place on the right side of the actions title. Images will only be displayed when used in a ModalDialog with the .actionSheet style.

style Style

Additional styling information to apply to the button. Use the style information to convey the type of action that is performed by the button. For a list of possible values, see the constants in ModalDialogAction.Style.

object Any?

Any "object" that you'd like access to in the handler.

handler ((Modal​Dialog​Action) -> Void)?

A closure to execute when the user selects the action. This block has no return value and takes the selected action object as its only parameter.

Properties

title

public var title: String

The title of the action's button.

image

public var image: UIImage? 

The image to place next to the actions title.

Images will only be displayed when used in a ModalDialog with the .actionSheet style.

right​Image

public var rightImage: UIImage? 

style

public var style: Style

The style that is applied to the action's button.

is​Enabled

public var isEnabled: Bool = true  

A boolean value indicating whether the action is currently enabled.

The default value of this property is true. Changing the value to false causes the action to appear dimmed in the resulting dialog. When an action is disabled, taps on the corresponding button have no effect.

object

public var object: Any? 

Anything that you'd like to access in the handler.

ok

public static var ok: ModalDialogAction  

A general OK action that dismisses the dialog.

cancel

public static var cancel: ModalDialogAction  

A general Cancel action that dismisses the dialog.

Methods

make(title:​image:​right​Image:​style:​object:​handler:​)

public static func make(
    title: String, image: UIImage? = nil, rightImage: UIImage? = nil, style: Style,
    object: Any? = nil, handler: ((ModalDialogAction) -> Void)? = nil) -> ModalDialogAction  

Create and return an action with the specified title and behavior.

Actions are enabled by default when you create them.

Parameters

title String

The text to use for the button title.

image UIImage?

The image to place next to the actions title. Images will only be displayed when used in a ModalDialog with the .actionSheet style.

right​Image UIImage?

The image to place on the right side of the actions title. Images will only be displayed when used in a ModalDialog with the .actionSheet style.

style Style

Additional styling information to apply to the button. Use the style information to convey the type of action that is performed by the button. For a list of possible values, see the constants in ModalDialogAction.Style.

object Any?

Any "object" that you'd like access to in the handler.

handler ((Modal​Dialog​Action) -> Void)?

A closure to execute when the user selects the action. This block has no return value and takes the selected action object as its only parameter.