设置UIButton中title的位置

有些时候我们想让UIButton的title居左对齐,我们设置btn.textLabel.textAlignment = UITextAlignmentLeft是没有作用的,我们需要设置

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

但是问题又出来,此时文字会紧贴到做边框,我们可以设置btn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);使文字距离做边框保持10个像素的距离。

你可能感兴趣的:(设置UIButton中title的位置)