UIButton select state's image appears behind normal state's image
I have a UIButton which has images set for both Normal and Selected State. From what I understand, when you switch the button.selected state to YES / NO, it should toggle between the two images. It sure does. But the selected state image always apear behind the normal state one.
The reason I can see this is because my normal state is a play button and the middle triangle is basically transparent. I can see the pause button appear behind it.
Anyone know what the problem is and, maybe how to fix it?
Managed to fix it by not using state variable to do it. I'm just explicitly setting the image each time. Kinda lame but works.
I also had this problem and it may be a bug so I will be checking with Apple. I had the following code, yet the "Selected State" Image and Text would not display.
[btnConfirm setSelected: YES]; [btnConfirm setEnabled: NO]; [btnConfirm setAlpha: .6];
So if the item had been previously confirmed, I didn't want the user to be able to tap the button again ([btnConfirm setEnabled: NO]). I wanted the wording to change for CONFIRM to CONFIRMED, and I wanted a custom Checkmark image to be displayed as well. Finally I wanted the button to appear "Grayed-Out" ([btnConfirm setAlpha: .6]).
Well this didn't work until I removed the [btnConfirm setEnabled: NO] statement. For some reason when the button is Disabled it can't have a "Selected" state. I guess it makes sense, but why are they mutually exclusive, I can't explain, so I will report my issue. in the mean time I may also try Highlighted...
I resolved my issue by just using the Disabled state. I removed the [btnConfirm setSelected: YES] because its no longer needed. The Disabled state of the button is automatically set once the btnConfirm.Enabled is set to NO.
This resolved all of my issues.