我试图给我的Swift应用程序中的某些文本添加下划线。这是代码我目前:在Swift中添加NSUnderlineStyle.PatternDash到NSAttributedString?
let text = NSMutableAttributedString(string: self.currentHome.name)
let attrs = [NSUnderlineStyleAttributeName:NSUnderlineStyle.PatternDash]
text.addAttributes(attrs, range: NSMakeRange(0, text.length))
homeLabel.attributedText = text
但我上text.addAttributes
行此错误:
NSString
不相同NSObject
我如何添加包含属性在一个枚举NSMutableAttributedString在Swift中?
请问您可以用swift4语法更新您的代码。 – Vats 2017-12-27 11:08:36
@Vats,已更新。看一看。 – vacawama 2017-12-27 13:59:50