我發現如何設置字母間距到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).
確切位置在哪裏出了問題?請發佈不適合你的代碼。 –
更新爲你看破碎的代碼。 –