Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: How to disable Fading in and out effect of UIButton

First of all, sorry for the title and asking this incredibly question but I simply couldn't figure it out. Also, since it is not related to code, I don't have code to show

I am working on an app and using iOS7 and I created a button from IB, set its background image to an image I designed. Connected it with header and set its touch up inside action as an IBAction

Yet, here is my problem. Whenever I click on the button, as an effect the image fades half transparent. I do not want this default attribute. I checked all the states on IB (highlighted, disabled, selected) and couldn't figure it out.

If I create the same button programmatically, only the text color changes, however when I set the background image, image fades (perhaps to indicate the button being pressed). How can I remove this effect?

like image 810
Ali Avatar asked Dec 20 '13 01:12

Ali


People also ask

How do I turn off highlighting in Uibutton?

make your button Type - "Custom" and Uncheck - Highlighted Adjust image and you are done.

How do I disable UI button?

The quickest way to disable the button in Swift is to simply set the button's isEnabled property to false. For example button. isEnabled = false.


2 Answers

A bit late but I believe this would solve the problem

in the xib file, set the button's type to Custom.

My button was set to system and when pressed on, it shows transparency and has a little fade in effect. Once I changed it to custom this effect is gone.

This cannot be changed once button is created. only in xib or when the button is first created.

like image 197
user1610613 Avatar answered Nov 15 '22 16:11

user1610613


have you tried this one yourButton.adjustsImageWhenHighlighted = NO?

like image 33
tassar Avatar answered Nov 15 '22 15:11

tassar