我发现如何设置字母间距到UILabel(here),但此方法不适用于UIButtons。有谁知道该怎么做?如何在Swift中更改UIButton的字母间距?
这里是我使用
let buttonString = agreementButton.attributedTitleForState(.Normal) as! NSMutableAttributedString
buttonString.addAttribute(NSKernAttributeName, value: 1.0, range: NSMakeRange(0, buttonString.length))
agreementButton.setAttributedTitle(buttonString, forState: .Normal)
这引发了我的错误代码:'NSConcreteAttributedString' (0x19e508660) to 'NSMutableAttributedString' (0x19e506a40).
确切位置在哪里出了问题?请发布不适合你的代码。 –
更新为你看破碎的代码。 –