views:

52

answers:

2

I want to disable my UIButton, so I call:

button.enabled = FALSE;

However this makes the button see-through and I can see the elements underneath it. I don't mind that it changes colour, I just don't want it to be see-through.

I've tried ticking the boxes for 'opaque' and 'clip subviews' in IB, but no joy.

Is there an easy way to fix this? I suppose I could put a UIImageView with the same button image behind it, but it's hardly an elegant solution.

Thanks all!!

Michael

+1  A: 

In interface builder select your button and then take a look at the button attributes. There is a drop down menu for default, highlighted, selected or disabled state configurations - select disabled and then adjust the alpha property.

mbehan
Aaaah, thanks, I've somehow never noticed that! However, when I select the disabled state configuration, nothing in the 'View' panel changes, the alpha is still at 1, and the checkboxes for 'opaque' etc remain the same regardless of which state configuration is selected. The only thing that changes is the Text Color and Shadow Color. So the problem remains...
Smikey
+2  A: 

Try userInteractionEnabled property:

button.userInteractionEnabled = NO;
jamapag
Perfect! Thanks - I should really have thought of that :D
Smikey