EXTENSION
public extension UIButton
@IBInspectable var normalStateBackgroundColor: UIColor?
@IBInspectable var disabledStateBackgroundColor: UIColor?
@IBInspectable var highlightedStateBackgroundColor: UIColor?
@IBInspectable var selectedStateBackgroundColor: UIColor?
@IBInspectable var titleImageSpacing: CGFloat
var isTitleImagePositionReversed: Bool
var backgroundImageView: UIImageView?
func setBackgroundColor(_ color: UIColor, for state: UIControl.State)
Set background color for state
- Parameters:
- color: color
- state: state
Name | Description |
---|---|
color | color |
state | state |
func centerTextAndImage(spacing: CGFloat, forceRightToLeft: Bool)
Adjust contentEdgeInsets
, imageEdgeInsets
and titleEdgeInsets
with appropriate value so as to make a specified spacing between the button's title and image.
-
Parameters:
- spacing: The desired spacing to make.
- forceRightToLeft: Whether the content of the button is in
forceRightToLeft
semantic.
Name | Description |
---|---|
spacing | The desired spacing to make. |
forceRightToLeft | Whether the content of the button is in forceRightToLeft semantic. |
func addAction(for controlEvent: UIControl.Event, closure: @escaping () -> Void)
Button action for event
- Parameters:
- controlEvent: Event
- closure: Closure to run
Name | Description |
---|---|
controlEvent | Event |
closure | Closure to run |