iOS 10.3: NSStrikethroughStyleAttributeName is not rendered if applied to a sub range of NSMutableAttributedString(iOS 10.3:如果应用于 NSMutableAttributedString 的子范围,则不会呈现 NSStrikethroughStyleAttributeName)
问题描述
如果应用范围不是整个字符串范围,则不会呈现作为属性添加到 NSMutableAttributedString
实例的删除线(单、双...).
A strikethrough (single, double, ...) added as attribute to an instance of NSMutableAttributedString
is not rendered if the apply range is not the whole string range.
使用 addAttribute(_ name: String, value: Any, range: NSRange)
, insert(_ attrString: NSAttributedString, at loc: Int)
, append(_attrString: NSAttributedString)
, ...
This happens using addAttribute(_ name: String, value: Any, range: NSRange)
, insert(_ attrString: NSAttributedString, at loc: Int)
, append(_ attrString: NSAttributedString)
, ...
在早期的 iOS 10.3 测试版中被 Apple 破坏,在 10.3 最终版中未修复.
Broken by Apple in early iOS 10.3 betas, and not fixed in 10.3 final.
信用:https://openradar.appspot.com/31034683
推荐答案
添加一个 NSBaselineOffsetAttributeName
,如解释 here,属性字符串带回删除线.覆盖 drawText:in:
可能会很慢,尤其是在 Collection View 或 Table View Cells 上.
Adding a NSBaselineOffsetAttributeName
, as explained here, to the attributed string brings back the strikethrough line. Overriding drawText:in:
can be slow especially on Collection View or Table View Cells.
这篇关于iOS 10.3:如果应用于 NSMutableAttributedString 的子范围,则不会呈现 NSStrikethroughStyleAttributeName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 10.3:如果应用于 NSMutableAttributedString 的子范围,则不会呈现 NSStrikethroughStyleAttributeName


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01