Use this
let button = UIButton(type: .roundedRect)
button.frame = CGRect(x: 20, y: 20, width: 200, height: 72)
button.setTitle("مرحبا", for: .normal)
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0)
button.contentHorizontalAlignment = .center
self.view.addSubview(button)
And change the button.titleEdgeInsets
as preferred.
solved How to set the position of title of button [closed]