Button
@available(iOS 9.0, *)
public class Button : UIButton
A UIButton that handles its own action.
-
Creates a UIButton
Declaration
Swift
public init( title: String, titleColor: UIColor? = nil, backgroundColor: UIColor? = nil, forEvent event: UIControl.Event = .touchUpInside, action: (() -> Void)? = nil )
Parameters
title
Text used for the button’s title
titleColor
Color used for the title’s font (Default: nil)
backgroundColor
Color used for the button’s background color (Default: nil)
forEvent
UIControl event for when to fire action (Default: .touchUpInside)
action
Closure for the the button’s action (Default: nil)
-
Creates a UIButton with a label view
Declaration
Swift
public init( forEvent event: UIControl.Event = .touchUpInside, action: (() -> Void)? = nil, labelView: () -> UIView )
Parameters
forEvent
UIControl event for when to fire action (Default: .touchUpInside)
action
Closure for the the button’s action
labelView
The view to embed
-
Update the button’s action
Declaration
Swift
@discardableResult public func setAction(_ action: (() -> Void)?) -> Self