Class
DSIconButton
@IBDesignable public final class DSIconButton: UIButton
An Anatomy-styled, icon-only push button element that displays a standard icon (DSIconRenderingType) as well as all normal UIButton functionality. No title text is allowed.
For storyboards, add a UIButton to your view and change the class name to DSIconButton. BE SURE THE TYPE IS SET TO CUSTOM otherwise some colors won't show correctly.
If the button performs an asynchronous operation, you can present a spinning indicator by setting isLoading to true. This will also disable the button.
Initialize and set properties as needed.
let button = DSIconButton(icon: .gear)
Relationships
Conforms To
UIButton
Initializers
init(icon:)
public init(icon: DSIconRenderingType)
Initializes and returns a newly allocated DSButton with the specified icon.
Parameters
Name | Type | Description |
---|---|---|
icon | DSIconRenderingType |
The icon for DSIconButton. Can be changed after initialization as well. |
Properties
iconString
@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.
isEnabled
public override var isEnabled: Bool
isHighlighted
public override var isHighlighted: Bool
isSelected
public override var isSelected: Bool
isLoading
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.
buttonType
public override var buttonType: UIButton.ButtonType
intrinsicContentSize
public override var intrinsicContentSize: CGSize
accessibilityLabel
public override var accessibilityLabel: String?
Methods
setTitle(_:for:)
public override func setTitle(_ title: String?, for state: UIControl.State)
setAttributedTitle(_:for:)
public override func setAttributedTitle(_ title: NSAttributedString?, for state: UIControl.State)
prepareForInterfaceBuilder()
public override func prepareForInterfaceBuilder()