esk*_*imo 2 nsattributedstring strikethrough ios swift
遇到一些删除线才能正常工作的问题。目前,我正在执行以下操作:
theString.addAttributes([
NSAttributedStringKey.strikethroughStyle: NSUnderlineStyle.styleSingle.rawValue,
NSAttributedStringKey.strikethroughColor: UIColor.white
], range: NSMakeRange(0, 1))
Run Code Online (Sandbox Code Playgroud)
它没有显示任何形式的删除线。有任何想法吗?我似乎找不到任何有效的方法。
我用它来删除Xcode9 / iOS11 / Swift4 env中的文本
let strokeEffect: [NSAttributedStringKey : Any] = [
NSAttributedStringKey.strikethroughStyle: NSUnderlineStyle.styleSingle.rawValue,
NSAttributedStringKey.strikethroughColor: UIColor.red,
]
let strokeString = NSAttributedString(string: "text", attributes: strokeEffect)
Run Code Online (Sandbox Code Playgroud)
斯威夫特 5.1
let attributedText : NSMutableAttributedString = NSMutableAttributedString(string: "Your Text")
attributedText.addAttributes([
NSAttributedString.Key.strikethroughStyle: NSUnderlineStyle.single.rawValue,
NSAttributedString.Key.strikethroughColor: UIColor.lightGray,
NSAttributedString.Key.font : UIFont.systemFont(ofSize: 12.0)
], range: NSMakeRange(0, attributedText.length))
Run Code Online (Sandbox Code Playgroud)
我正在分享最新动态。对于 Swift4、iOS 11.3
attributedText.addAttributes([
NSStrikethroughStyleAttributeName:
NSUnderlineStyle.styleSingle.rawValue,
NSStrikethroughColorAttributeName:
UIColor.black], range: textRange)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2821 次 |
| 最近记录: |