I want to put an image on the right side of the button and the text on the left side. But I want the text to be 20 points from the left margin of the button and the image to be 20 points from the right margin. How would I do that? I want to use the native image and label within a UIButton, I don't want to put anything on top of the button. Here is an example:
Use
button.semanticContentAttribute = .forceRightToLeft
For other methods you can refer this and this.
Very simple and easy solution: Use UIView containing UIButton and UIImage, as shown in this snapshot.
This will make easy to handle button action, properties and customise image position & size according to your requirement. Try this.
You can update the image and title insets either programmtically or inside attribute inspector. Here is the screenshot:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With