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 State Swift.struct.
Discussion
At a minimum, always set an image for the normal state when associating images to a button. If you don’t specify an image for the other states, the button uses the image associated with normal. If you don’t specify an image for the normal state, the button uses a system value.