How to set the title of UIButton as left alignment?
Set the contentHorizontalAlignment:
emailBtn.contentHorizontalAlignment = .left;
You might also want to adjust the content left inset otherwise the text will touch the left border:
emailBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
// Swift 3 and up:
emailBtn.contentEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0);
You can also use interface builder if you don't want to make the adjustments in code. Here I left align the text and also indent it some:
Don't forget you can also align an image in the button too.:
In Swift 3+:
button.contentHorizontalAlignment = .left