Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Custom Button With A Depressed State

I realize that there has to be a a ton of guides to do this but I can't find it...

What I am trying to do is use a button with a custom image in it and when you press the button have the image change to another "pressed" version of the button.

like image 223
Mytheral Avatar asked Aug 30 '11 14:08

Mytheral


2 Answers

If you don't like James Webster's solution, you can also do the same through interface builder. Select your button and from the properties find the "state config" list and pick "Selected". Then if you set image, title etc, you will get different graphics and text if you do [button setSelected:YES];

like image 123
phi Avatar answered Sep 28 '22 11:09

phi


What I believe you need is:

[button setImage:image forState:UIControlStateSelected];
like image 43
James Webster Avatar answered Sep 28 '22 12:09

James Webster