I want my button title to be centered and simply selected word-wrap in the Attributes Inspector to have two lines.
But the second line is not displayed centered but starts at the same position as the first line (the first line is longer).
How can I center both lines? (I'm using Swift.)
You cannot set the text alignment of UIButton in interface builder. Create and connect an IBOutlet for the said button in interface builder, and use the following code in viewDidLoad method of the view controller.
ibOutletOfButton.titleLabel.textAlignment = NSTextAlignment.Center;
I hope it helps!:-)
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