DSButton

@IBDesignable
public final class DSButton : UIButton

An Anatomy-styled push button element. Includes properties for adding and positioning Anatomy icons as well as all normal UIButton functionality.

For storyboards, add a UIButton to your view and change the class name to DSButton. BE SURE THE TYPE IS SET TO CUSTOM otherwise some colors won’t show correctly.

Initialize and set properties as needed.

let button = DSButton(renderingType: .primary)

button.setTitle("Settings", for: .normal)
button.icon = .gear

If the button performs an asynchonous operation, you can present a spinning indicator by setting isLoading to true. This will also disable the button.

button.isLoading = true

Accessors

  • The visual style of the button. Can be changed after initialization.

    Declaration

    Swift

    public var renderingType: DSButtonRenderingType { get set }
  • The renderingType property representable by a String.

    This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are default, primary and tertiary. In code, use the renderingType property instead.

    Declaration

    Swift

    @IBInspectable
    public var renderingTypeString: String { get set }
  • An Anatomy icon to display next to the title. Can be positioned to the left or right of the title using imageLocation. Always displays as 24x24.

    Declaration

    Swift

    public var icon: DSIconRenderingType? { get set }
  • The icon property representable by a String.

    This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are left and right. In code, use the icon property instead.

    Declaration

    Swift

    @IBInspectable
    public var iconString: String? { get set }
  • Specifies which side of the title that the icon should display, left or right.

    Declaration

    Swift

    public var imageLocation: DSButtonImageLocationType { get set }
  • The imageLocation property representable by a String.

    This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are left and right. In code, use the imageLocation property instead.

    Declaration

    Swift

    @IBInspectable
    public var imageLocationString: String { get set }
  • When set to true, the button contents disappear and are replaced by a spinning indicator. The button will also become disabled. Use this when you want to keep the user from tapping the button during an asyncronous activity for example.

    Declaration

    Swift

    public var isLoading: Bool { get set }

Initializers

  • Initializes and returns a newly allocated Button with the specified renderingType.

    Declaration

    Swift

    public init(renderingType: DSButtonRenderingType)

    Parameters

    renderingType

    The renderingType to style DSButton. Can be changed after initialization as well.