ios - UITextView在更改字体后呈现奇怪的字符
问题描述
所以我有一个UITextView/NSTextView
通过NSMutableAttributedString
. 我注意到,当文本字体间距的一个小节发生变化时,一些奇怪的字符会在字体发生变化的地方呈现,请参见此 gif:
至少我NSMutableAttributedString
用以下块更新了一部分
attr.setAttributes([
.foregroundColor : textColor,
.font : UIFont.monospacedSystemFont(ofSize: fontSize, weight: .thin),
], range: range)
在奇怪的字符之前:
Hello
{
NSColor = "Catalog color: System labelColor";
NSFont = "\".AppleSystemUIFont 13.00 pt. P [] (0x7fed6ef77420) fobj=0x7fed6ef77420, spc=3.58\"";
}'''
nice stuff
'''{
NSColor = "Catalog color: System labelColor";
NSFont = "\".AppleSystemUIFontMonospaced-Regular 13.00 pt. P [] (0x7fed6ef7aa50) fobj=0x7fed6ef7aa50, spc=8.04\"";
}
Hello{
NSColor = "Catalog color: System labelColor";
NSFont = "\".AppleSystemUIFont 13.00 pt. P [] (0x7fed6ef77420) fobj=0x7fed6ef77420, spc=3.58\"";
}
当奇怪的字符正在渲染时:
Hello
'''
nice stuff
''
Hello{
NSColor = "Catalog color: System labelColor";
NSFont = "\".AppleSystemUIFont 13.00 pt. P [] (0x7fed6ef77420) fobj=0x7fed6ef77420, spc=3.58\"";
}
有没有遇到过类似的奇怪工件和问题?
解决方案
使用时,NSTextStorage
如果在对范围进行样式设置后不使用标记范围,NSTextStroage.edited
则最终可能会出现一些这种伪影。
推荐阅读
- sql-server - 输出具有多个属于不同项目组配置的销售项目的 SQL 单个事务
- c++ - 什么保证两个不相关线程中的不同不相关对象没有(不可避免的)竞争条件?
- java - 排序坐标系
- python - 如何使用 Cloudflare SSL 证书设置简单的 https 服务器?
- javascript - 滚动时顶部的粘性元素
- c# - RedirectToAction 不调用动作
- haskell - Why does the inliner choke on this construct?
- amazon-web-services - Aws Appsync 解析器:如何创建解析器以更新列表映射 (DynaMoDB) 中的项目
- c - C 中的 for 循环的 fgets() 问题
- android - 从数据库中检索数据的小部件