Skip to content

Latest commit

History

History
106 lines (75 loc) 路 2.14 KB

File metadata and controls

106 lines (75 loc) 路 2.14 KB

EXTENSION

UIButton

public extension UIButton

Properties

normalStateBackgroundColor

@IBInspectable var normalStateBackgroundColor: UIColor?

disabledStateBackgroundColor

@IBInspectable var disabledStateBackgroundColor: UIColor?

highlightedStateBackgroundColor

@IBInspectable var highlightedStateBackgroundColor: UIColor?

selectedStateBackgroundColor

@IBInspectable var selectedStateBackgroundColor: UIColor?

titleImageSpacing

@IBInspectable var titleImageSpacing: CGFloat

isTitleImagePositionReversed

var isTitleImagePositionReversed: Bool

backgroundImageView

var backgroundImageView: UIImageView?

Methods

setBackgroundColor(_:for:)

func setBackgroundColor(_ color: UIColor, for state: UIControl.State)

Set background color for state

  • Parameters:
    • color: color
    • state: state

Parameters

Name Description
color color
state state

centerTextAndImage(spacing:forceRightToLeft:)

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

Name Description
spacing The desired spacing to make.
forceRightToLeft Whether the content of the button is in forceRightToLeft semantic.

addAction(for:closure:)

func addAction(for controlEvent: UIControl.Event, closure: @escaping () -> Void)

Button action for event

  • Parameters:
    • controlEvent: Event
    • closure: Closure to run

Parameters

Name Description
controlEvent Event
closure Closure to run