This is easy, first you need to do this. Goto your interface builder. Follow these steps -
- Select the
UIButton
element. Open the right-hand sidebar which gives attributes about the button. Select Type
of your button as Custom
.
- Now in there, look for
state config
. The various states for a button - default, highlighted, selected, disabled. Define various different images as you want in image
. Basically select images such that the effect you want is satisfied.
- Now, this automatically handles change in appearance of the button element depending on the state of the button.
- But sometimes, you would want to change the state manually, through code. This can be done like so -
[yourButton setSelected:BOOL]
or [yourButton setHighlighted:BOOL]
or [yourButton setEnabled:BOOL]
Hope this helps...
Update: See the screenshot - This shot shows that there are states defined, 'default', 'highlighted'... this defines the states. You can define images for each of these states. Again, hope this helps...
