当我将 adjustsFontSizeToFitWidth 设置为按钮 UILabel 时,文本会出现在按钮框架的一侧,我不知道为什么?
这是我的代码:
shareBtn = UIButton()
shareBtn.setTitle(IconsConstants.share, forState: UIControlState.Normal)
shareBtn.titleLabel?.font = UIFont.iconmoonFont(100)
shareBtn.titleLabel?.adjustsFontSizeToFitWidth = true;
shareBtn.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
shareBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center
//EdgeInsets
shareBtn.contentEdgeInsets = UIEdgeInsets.init(top: 10, left: 10, bottom: 10, right: 10)
结果如下: