Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton sets dark when it is selected (I want to avoid this)

Tags:

ios

iphone

I'm developing an iOS 4 application.

I'm using a custom uibutton to make an image clickable. When user taps over the image, it will disappear.

It's not very pretty to see that the image gets black, then turns to its original color, and then disappear.

Is there a way to disable that effect?

like image 439
VansFannel Avatar asked Dec 14 '11 17:12

VansFannel


2 Answers

You will need to set the property adjustsImageWhenHighlighted to NO:

[button setAdjustsImageWhenHighlighted:NO];

Alternatively you can set the same image for all controlStates of the button.

like image 176
Felix Lamouroux Avatar answered Nov 15 '22 08:11

Felix Lamouroux


You need to set the property Shows Touch On Highlight to enabled.

Programmatically you can do that with:

[button setShowsTouchWhenHighlighted:YES];
like image 36
Matteo Alessani Avatar answered Nov 15 '22 07:11

Matteo Alessani