adrgrondin
adrgrondin

Reputation: 668

How to disable UIButton highlight when pressed in a nib file?

I have a UIButton inside a UIView in a nib file and I want to disable the highlight when the button is pressed.

However unchecking the box (for all states) 'Highlighted Adjust Image' in Interface Builder for the button doesn't remove the highlight.

I have also tried to disable the highlight programmatically with in an @IBAction:

@IBAction func myButtonTapped(_ sender: UIButton) {
    sender.adjustsImageWhenHighlighted = false
}

But the highlight is still here when the button is pressed.

How to disable the highlight when none of the above methods work?

Upvotes: 0

Views: 483

Answers (1)

iVarun
iVarun

Reputation: 6631

To use adjustsImageWhenHighlighted your UIButton type should be set to custom.

Upvotes: 2

Related Questions