funroll
funroll

Reputation: 37093

UIButton keep content on top of backgroundImage

I have a UIButton and I'm setting a background image on it:

[self.button setBackgroundImage:[UIImage imageNamed:@"button-background"] forState:UIControlStateNormal];

I want the content of the button to stay on top of the background image, and not be affected by it. So when the button content is text, the font color of the text would be unaffected by changing the background image. I'd like it to behave similarly when the button content is an image.

What's the best way to achieve this behavior?

Upvotes: 0

Views: 62

Answers (1)

Mark McCorkle
Mark McCorkle

Reputation: 9414

Setting the background of the button does exactly what you're asking. However, make sure your button is in the state you're setting the background image for. Text will appear over this image based on your settings.

forState:UIControlStateNormal (Highlighted, selected, etc)

Upvotes: 1

Related Questions