UIButton的title位置

有些时候我们想让UIButton的title居左对齐,

我们设置btn.textLabel.textAlignment = UITextAlignmentLeft是没有作用的,

我们需要设置

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

但是问题又出来,此时文字会紧贴到做边框,

我们可以设置btn.contentEdgeInsets = UIEdgeInsetsMake(0,1000);使文字距离做边框保持10个像素的距离。

原文地址:https://www.cnblogs.com/hbf369/p/2616525.html