How to disable a button with an image without decreasing alpha in obejective C?

After creating a round rectangular button, I turned off the button, and the button alpha remains at 1 unless I manually reduced the alpha to 0.5. But after inserting the image on the button, the alpha of the button will be automatically set to 0.5, even after setting alpha-1 after turning off the button.

I would like to disable the button containing the image without affecting it.

Can anybody help me?

Hi,

Bean

+5
source share
3 answers

Look at the property UIButton adjustsImageWhenDisabled. Setting that NO should do what you want.

There is also a similar property for highlighted buttons.

+8

, , . , UIControlStateDisabled. :

- (void)setImage:(UIImage *)image forState:(UIControlState)state;

xib.

0

Yes, the adjustsImageWhenDisabled property and setting its NO is the way to go.

0
source

All Articles