UIButton设置UIControlContentHorizontalAlignment调整文字对齐方式

 

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

上一篇:UIButton 中图片和文字的排列方式(Swift)


下一篇:UIButton设置图片和文字(一)