Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable UIButton highlight on click?

How to disable button highlight effect on click? Have custom button with white bg color and DarkGray text color. The problem is the text becomes white on button click. Already tried but none of them worked:

a. Did uncheck "Highlighted Ajusts Image" in interface builder.

b. Tried setting highlighted = NO in button pressed method:

((UIButton *)sender).highlighted = NO

c. Tried setting the same title for highlihted state:

[button setTitle:[button titleForState:UIControlStateNormal] forState:UIControlStateHighlighted];

Any suggestions?

like image 216
Centurion Avatar asked Jul 08 '13 13:07

Centurion


2 Answers

You could also make the UIButton type : custom from StoryBoard

Custom button

This should strip down any system behavior for you. (I think)

like image 121
Paul Brewczynski Avatar answered Nov 10 '22 07:11

Paul Brewczynski


This is a solution for buttons that have images. In the storyboard, there is a property called HighlightedAdjustsImage which is On by default. Disable that and your button image will not show any highlighted properties.

like image 25
Rajeev Bhatia Avatar answered Nov 10 '22 08:11

Rajeev Bhatia