Combining images to make a UIButton?
If I have one png which is basically a butt开发者_运维问答on 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)
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];
精彩评论