我正在尝试使用带有虚线下划线的 NSMutableAttributedString 下面是我的代码,但似乎没有一个模式有效,我是否遗漏了什么?
var str : NSMutableAttributedString = NSMutableAttributedString(string: "HelloWorld")
str.addAttribute(NSUnderlineStyleAttributeName , value: NSNumber(integer:(NSUnderlineStyle.PatternDot).rawValue), range: NSMakeRange(0, str.length))
最佳答案
你必须这样做:
Xcode 10 • Swift 4.2 或更高版本
yourLabel.attributedText = NSAttributedString(string: "Hello World !!!", attributes: [.underlineStyle: NSUnderlineStyle.patternDot.union(.single).rawValue])
注意:对于旧的 Swift 语法检查编辑历史
关于ios - 如何使用 NSUnderlineStyle.PatternDot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28052823/