Instance Method

setImage(_:for:)

Sets the image to use for the specified state.

Declaration

func setImage(_ image: UIImage?, for state: UIControl.State)

Parameters

image

The image to use for the specified state.

state

The state that uses the specified image. The values are described in UIControl.State.

Discussion

In general, if a property is not specified for a state, the default is to use the normal value. If the normal value is not set, then the property defaults to a system value. Therefore, at a minimum, you should set the value for the normal state.

See Also

Configuring Button Presentation

var adjustsImageWhenHighlighted: Bool

A Boolean value that determines whether the image changes when the button is highlighted.

var adjustsImageWhenDisabled: Bool

A Boolean value that determines whether the image changes when the button is disabled.

var showsTouchWhenHighlighted: Bool

A Boolean value that determines whether tapping the button causes it to glow.

func backgroundImage(for: UIControl.State) -> UIImage?

Returns the background image used for a button state.

func image(for: UIControl.State) -> UIImage?

Returns the image used for a button state.

func setBackgroundImage(UIImage?, for: UIControl.State)

Sets the background image to use for the specified button state.

var tintColor: UIColor!

The tint color to apply to the button title and image.