Sal*_*mua 12 setattribute nsattributedstring ios nsmutableattributedstring swift
我在按钮attributesTitle中添加了一些属性
let attr = NSMutableAttributedString(string: currTitle)
attr.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRange(0, attr.length))
attr.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(0, attr.length))
currButton?.setAttributedTitle(attr, forState: UIControlState.Normal)
Run Code Online (Sandbox Code Playgroud)
按钮点击后如何从中删除NSStrikethroughStyleAttributeName?
aya*_*aio 10
使用removeAttribute方法:
attr.removeAttribute(NSStrikethroughStyleAttributeName, range: NSMakeRange(0, attr.length))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4646 次 |
| 最近记录: |