In Swift 4, note the use of contentEdgeInsets
not titleEdgeInsets
:
btn.contentEdgeInsets = UIEdgeInsetsMake(8, 8, 8, 8)
btn.titleLabel?.lineBreakMode = .byWordWrapping
That will make the button wrap its text and keep it one line as long as there is a space for it + adding some padding around