I am trying to set the title on a Button to left. But everything i tried is not working.
With:
UILabelButton.titleLabel.textAlignment = .Left
Or:
UILabelButton.contentVerticalAlignment = UIControlContentVerticalAlignment // There is no left
The button title is still centered.
Is there another Property?
You have to use UIControlContentHorizontalAlignment. Left . You need to use horizontal not vertical . Save this answer.
To align a text view along the horizontal axis, you need to use . frame() modifier with maxWidth set to . infinity and alignment to the alignment you want.
Use contentHorizontalAlignment
.You have to use UIControlContentHorizontalAlignment.Left
.You need to usehorizontal
not vertical
.
btn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left
Swift 3.x
btn.contentHorizontalAlignment = .left
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