iOS开发-UIButton中title位置设置

来源:互联网 发布:ppt 图标 知乎 编辑:程序博客网 时间:2024/05/29 14:21

让UIButton的title居左对齐,我们设置

btn.textLabel.textAlignment = UITextAlignmentLeft

是没有作用的

我们需要设置下面属性的才有作用

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

但是问题又出来,此时文字会紧贴到做边框,我们可以设置

btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);

0 0