小编A.S*_*dky的帖子

如何在Swift中更改UIButton的字母间距?

我已经找到了如何将字母间距设置为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).

uibutton letter-spacing swift

9
推荐指数
3
解决办法
7333
查看次数

标签 统计

letter-spacing ×1

swift ×1

uibutton ×1