iOS开发-UIButton中title位置设置

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

btn.textLabel.textAlignment = UITextAlignmentLeft

是没有作用的

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

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

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

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

你可能感兴趣的:(ios,ios开发,UIButton)