UIButton 继承自UIControl,所以可以对UIControlContentHorizontalAlignment进行设置
btn.setImage(UIImage.init(named: "unSelected"), for: UIControl.State.normal) btn.setImage(UIImage.init(named: "selected"), for: UIControl.State.selected) btn.contentHorizontalAlignment = .right
https://blog.csdn.net/timtian008/article/details/53611744