Objective-C toggle on/off images

December 15, 2009 § Leave a comment

It’s simple way to use a custom image for UIButton and set the UIButton to switch in between the UIControlStateNormal & UIControlStateSelected.

This is a common use case to show a play or pause button depending on he UIButton state status.

UIButton * customButton=[UIButton buttonWithType:UIButtonTypeCustom];

[customButton setBackgroundImage:[UIImage imageNamed:@”Play.png”] forState:

[customButton setBackgroundImage:[UIImage imageNamed:@”Pause.png”] forState:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

What’s this?

You are currently reading Objective-C toggle on/off images at Web Builders.


%d bloggers like this: