SKButton
open class SKButton : UIButton
SKButton
is a subclass of UIButton
that enables setting different background color for different states.
-
Overriding the original method to update the button background when the button is highlighted.
Declaration
Swift
open override var isHighlighted: Bool { get set }
-
Overriding the original method to update the button background when the button is enabled.
Declaration
Swift
open override var isEnabled: Bool { get set }
-
Overriding the original method to update the button background when the button is selected.
Declaration
Swift
open override var isSelected: Bool { get set }
-
init
via code.Declaration
Swift
public override init(frame: CGRect)
-
init
via IB.Declaration
Swift
public required init?(coder aDecoder: NSCoder)
-
Sets the background color for a given state.
Declaration
Swift
public func setColor(_ color: UIColor, for state: UIControl.State)
Parameters
color
The color to assign.
state
The state to which the color should be assigned.
-
Returns the assigned color to a given state, if any.
Declaration
Swift
public func getColor(for state: UIControl.State) -> UIColor?
Parameters
state
The state of which the color should be retrieved.
Return Value
The color assigned to the state if found, otherwise nil.
-
The color of a given state. This does not reflect the color assigned to that state, but rather the color that will show up, since if no color is assigned it fallsback to
.normal
state.Declaration
Swift
public func color(for state: UIControl.State) -> UIColor
Parameters
state
The state of which the color should be retrieved.
Return Value
The color that will appear given that state.
-
Sets the title opacity of a given state.
Declaration
Swift
public func setOpacity(_ opacity: CGFloat, for state: UIControl.State)
Parameters
opacity
The desired opacity.
state
The button state to modify.
-
Checks the title opacity of a given state.
Declaration
Swift
public func getOpacity(for state: UIControl.State) -> CGFloat?
Parameters
state
The button state.
Return Value
The opacity of that state if assigned, otherwise nil.
-
The title opacity of a given state. This does not reflect the opacity assigned to that state, but rather the opacity that will show up, since if no opacity is assigned it fallsback to
.normal
state.Declaration
Swift
public func opacity(for state: UIControl.State) -> CGFloat
Parameters
state
The state of the button.
Return Value
The opacity that will appear given that state.