Button

public struct Button : View

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

         Button {
             // click action
         } builder: {
             // content
         }
  • The node behind the button.

    Declaration

    Swift

    public var node: ArgoKitNode? { get }
  • Initializer

    Declaration

    Swift

    public init(action: @escaping () -> Void, @ArgoKitViewBuilder builder: @escaping () -> View)

    Parameters

    action

    The action to perform when the user triggers the button.

    builder

    A view builder that creates the content of this button.

  • Initializer

    Declaration

    Swift

    public init(text: @autoclosure @escaping () -> String?, action: @escaping () -> Void)

    Parameters

    text

    A string that describes the purpose of the button’s action.

    action

    The action to perform when the user triggers the button.

  • Sets the color of the text.

    Declaration

    Swift

    @discardableResult
    public func textColor(_ color: @autoclosure @escaping () -> UIColor?) -> Button

    Parameters

    color

    The color of the text.

    Return Value

    self

  • Sets the font of the text.

    Declaration

    Swift

    @discardableResult
    public func font(_ value: @autoclosure @escaping () -> UIFont) -> Button

    Parameters

    value

    The font of the text.

    Return Value

    self

  • Sets the font of the text.

    Declaration

    Swift

    @discardableResult
    public func font(name: @autoclosure @escaping () -> String? = nil, style: @autoclosure @escaping () -> AKFontStyle = .default, size: @autoclosure @escaping () -> CGFloat) -> Button

    Parameters

    name

    The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font.

    style

    The text style for which to return a font. See AKFontStyle for recognized values.

    size

    The size (in points) to which the font is scaled. This value must be greater than 0.0.

    Return Value

    self

  • Sets the color of the text.

    Declaration

    Swift

    @discardableResult
    public func textColor(red r: @autoclosure @escaping () -> Int, green g: @autoclosure @escaping () -> Int, blue b: @autoclosure @escaping () -> Int, alpha a: @autoclosure @escaping () -> CGFloat = 1) -> Button

    Parameters

    r

    The red value of the color object. 0~255

    g

    The green value of the color object. 0~255

    b

    The blue value of the color object. 0~255

    a

    The opacity value of the color object. 0.0~1.0

    Return Value

    self

  • Sets the color of the text.

    Declaration

    Swift

    @discardableResult
    public func textColor(hex: @autoclosure @escaping () -> Int, alpha a: @autoclosure @escaping () -> Float = 1) -> Button

    Parameters

    hex

    The hex value of the color object

    a

    The opacity value of the color object. 0.0~1.0

    Return Value

    self

  • Sets the background image to use for the specified button state.

    Declaration

    Swift

    @discardableResult
    public func backgroundImage(image: @autoclosure @escaping () -> UIImage?, for state: @autoclosure @escaping () -> UIControl.State) -> Button

    Parameters

    image

    The background image to use for the specified state.

    state

    The state that uses the specified image. The values are described in UIControl.State.

    Return Value

    self

  • Sets the background image to use for the specified button state.

    Declaration

    Swift

    @discardableResult
    public func backgroundImage(named name: @autoclosure @escaping () -> String?, for state: @autoclosure @escaping () -> UIControl.State) -> Button

    Parameters

    name

    The name of the image asset or file. For images in asset catalogs, specify the name of the image asset. For PNG images, you may omit the filename extension. For all other file formats, always include the filename extension.

    state

    The state that uses the specified image. The values are described in UIControl.State.

    Return Value

    self