iOS - UIButton 的文字靠左显示

想要设置 UIButton 的文字靠左显示

  button.titleLabel.textAlignment = UITextAlignmentLeft

这句代码是对 button 中的 titleLabel 上的文字起作用

真正起作用的是:

   button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

你可能感兴趣的:(iOS - UIButton 的文字靠左显示)