cannyboy
cannyboy

Reputation: 24416

Combining images to make a UIButton?

If I have one png which is basically a button image with nothing inside of it:

----------------
|              |
----------------

How do I lay an image onto that, to make the image part of the button, like:

----------------
|    (image)   |
----------------

(I could just lay a UIImageView on top, but that would not inherit button properties, like going dark when pressed)

Upvotes: 0

Views: 205

Answers (1)

Matthias Bauch
Matthias Bauch

Reputation: 90117

use the image that is basically a button as the backgroundImage of the UIButton, and use the other image as the image of the UIButton.

[button setImage:[UIImage imageNamed:@"Foo"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"Bar"] forState:UIControlStateNormal];

Upvotes: 6

Related Questions