EnterpriseDS Documentation

Class DSButton

@IBDesignable public final class DSButton: UIButton  

An Enterprise-styled push button element. It includes properties for adding and positioning Enterprise 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

The renderingType decides the behavior and appearance of the button. Enterprise Button is supported by primary, secondary and tertiary. For older Anatomy-style buttons, which appear as teal green, use the anatomyPrimary, anatomyDefault and anatomyTertiary rendering types.

If the button performs an asynchronous operation, you can present a spinning indicator by setting isLoading to true. (Anatomy button styles only.)

anatomyButton.isLoading = true
DSButton DSButton UIButton UIButton DSButton->UIButton

Conforms To

UIButton

Initializers

init(rendering​Type:​)

public init(renderingType: DSButtonRenderingType)  

Initializes and returns a newly allocated DSButton with the specified renderingType.

Parameters

rendering​Type DSButton​Rendering​Type

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

Properties

rendering​Type

public var renderingType: DSButtonRenderingType = .primary  

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

rendering​Type​String

@IBInspectable public var renderingTypeString: String  

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.

icon

public var icon: DSIconRenderingType?  

An Enterprise icon to display next to the title. Can be positioned to the left or right of the title using imageLocation. Always displays as 24x24.

icon​String

@IBInspectable public var iconString: String?  

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.

image​Location

public var imageLocation: DSButtonImageLocationType = .leading  

Specifies which side of the title that the icon should display, left or right.

image​Location​String

@IBInspectable public var imageLocationString: String  

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.

is​Enabled

public override var isEnabled: Bool  

Control is updated when enabled status changes.

is​Highlighted

public override var isHighlighted: Bool  

Control is updated when highlighted status changes.

is​Selected

public override var isSelected: Bool  

Not supported by DSButton. DO NOT CALL.

is​Loading

public var isLoading: Bool = false  

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 asynchronous activity for example.

button​Type

public override var buttonType: UIButton.ButtonType  

accessibility​Label

public override var accessibilityLabel: String?  

intrinsic​Content​Size

public override var intrinsicContentSize: CGSize  

Methods

set​Title(_:​for:​)

public override func setTitle(_ title: String?, for state: UIControl.State)  

prepare​For​Interface​Builder()

public override func prepareForInterfaceBuilder()  

awake​From​Nib()

public override func awakeFromNib()  

layout​Subviews()

public override func layoutSubviews()