Now I want to alignment the text of button to the left with code , how to do ? and I code this :
button.titleLabel.textAlignment = UITextAlignmentLeft;
but it doesn't work.
Now I want to alignment the text of button to the left with code , how to do ? and I code this :
button.titleLabel.textAlignment = UITextAlignmentLeft;
but it doesn't work.
You have to use
contentVerticalAlignment
andcontentHorizontalAlignment
of the button.Use
ContentHorizontalAlignment
as belowSwift Code
Setting to button titleLable alignment also works perfectly.
For those who are using Swift 3
Above code align text to left border, so you might want little padding.