CreationKit Documentation

Class Button

public final class Button: UIButton  

A control that executes your custom code in response to user interactions.

Prefer to use make(style:isCritical:title:icon) to create a Button.

Button Button UIButton UIButton Button->UIButton

Nested Types

Button.Style

The style of the Button.

Conforms To

UIButton

Initializers

init(style:​is​Critical:​title:​icon:​)

public init(style: Style = .primary, isCritical: Bool = false, title: String? = nil, icon: UIImage? = nil)  

Creates a new Button instance.

Prefer to use make(style:isCritical:title:icon) instead.

Parameters

style Style

The style to use for the button. Defaults to .primary.

is​Critical Bool

true if the Button should be in the critical state. Defaults to false.

title String?

The title of the button, or nil for no title.

icon UIImage?

The image to place in the button, or nil for no image.

Properties

title

public var title: String? = ""  

The buttons title

icon

public var icon: UIImage? = nil  

An to display with or without the title

icon​Side

public var iconSide: LateralDirection = .left  

Where the icon should be placed, either on the left of the text, or the right of the text.

style

public var style: Style = .primary  

The style of the button. Can be mixed with isCritical.

is​Critical

public var isCritical: Bool = false

true if the button has a Critical style.

is​Enabled

public override var isEnabled: Bool  

is​Enabled​Publisher

public var isEnabledPublisher: AnyPublisher<Bool, Never>  

is​Highlighted

public override var isHighlighted: Bool  

Methods

make(style:​is​Critical:​title:​icon:​)

public static func make(style: Style = .primary, isCritical: Bool = false, title: String? = nil, icon: UIImage? = nil) -> Button  

Creates a new Button instance.

Parameters

style Style

The style to use for the button. Defaults to .primary.

is​Critical Bool

true if the Button should be in the critical state. Defaults to false.

title String?

The title of the button, or nil for no title.

icon UIImage?

The image to place in the button, or nil for no image.

title​Rect(for​Content​Rect:​)

public override func titleRect(forContentRect contentRect: CGRect) -> CGRect  

image​Rect(for​Content​Rect:​)

public override func imageRect(forContentRect contentRect: CGRect) -> CGRect