我已经找到了如何将字母间距设置为UILabel(此处),但此方法不适用于UIButtons.有谁知道怎么做?
这是我正在使用的代码
let buttonString = agreementButton.attributedTitleForState(.Normal) as! NSMutableAttributedString
buttonString.addAttribute(NSKernAttributeName, value: 1.0, range: NSMakeRange(0, buttonString.length))
agreementButton.setAttributedTitle(buttonString, forState: .Normal)
Run Code Online (Sandbox Code Playgroud)
它抛出了一个错误: 'NSConcreteAttributedString' (0x19e508660) to 'NSMutableAttributedString' (0x19e506a40).