jasongregori jasongregori - 1 year ago 97
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 Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download