views:

60

answers:

3

After creating a round rect button, i disabled the button and the alpha of the button stays at 1 unless i reduced the alpha to 0.5 manually. But after inserting an image to the button, the alpha of the button would be set to 0.5 automatically even after setting the alpha to 1 after disabling the button.

I would like to disable the button containing an image without affecting it's alpha.

Can anyone Help me?

Regards,

Bob

+4  A: 

Have a look at the UIButton's adjustsImageWhenDisabled property. Setting that to NO should do what you want.

There's also a similar property for highlighted buttons.

Thomas Müller
Thanks! This was what i was looking for. :)
A: 

When no image is set for the disabled state, the system may generate one by modifying the normal state image. To prevent that, set the same image for normal and UIControlStateDisabled. Either use:

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

Or set it in the xib.

drawnonward
A: 

yea the adjustsImageWhenDisabled property and setting it to NO is the way.

cheesebunz
Yes, Thanks for posting, Cheesebunz but you could have just left a comment on that answer instead of posting a new answer. lol =D