jasongregori jasongregori - 3 months ago 19
iOS Question

How do I put the image on the right side of the text in a UIButton?

I don't want to use a subview if I can help it. I want a UIButton with a background image, text, and an image in it. Right now when I do that the image is on the left side of the text. The background image, text, and image all have different highlight states.

Answer

Simplest solution:

button.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);
button.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
Comments