iOS 10.3:如果应用于 NSMutableAttributedString 的子范围,则不会呈现 NSStrikethroughStyleAttributeName [英] iOS 10.3: NSStrikethroughStyleAttributeName is not rendered if applied to a sub range of NSMutableAttributedString

查看:19
本文介绍了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), ...

在早期的 iO​​S 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆