Search code examples
iosswiftuikituibutton

How to disable UIButton getting highlighted when clicked?


I tried multiple solutions from stack overflow but no luck. I have set HighlightedAdjustsImage = false

In my Code :

button.backgroundColor = .clear
button.layer.borderWidth = 0

inside my IBAction for button I am changing image and also setting value of isSelected as :

*button.isSelected = !button.isSelected*

Inside storyboard enter image description here

what did i do wrong here?


Solution

  • The problem is the Style setting of your button in the storyboard (the second popup menu in your screenshot).

    Change the Style from Plain to Default and the button will start working according to your specification.

    enter image description here