ios - 将“动态字体大小”与 NSAttributedString 一起使用
问题描述
我正在尝试保存并稍后显示使用动态字体大小显示的格式化 NSAttributedString: UIFont.preferredFont(forTextStyle: .body)
。我目前:
- 创建 UITextView 并将其字体大小设置为
UIFont.preferredFont(forTextStyle: .body)
- 在 UITextView 中输入文本时,字体显示为
<UICTFont: 0x13de36a90> font-family: "UICTFontTextStyleBody"; font-weight: normal; font-style: normal; font-size: 17.00pt
- 保存 NSAttributedString
- 再次打开并加载 UITextView 时,字体显示为
<UICTFont: 0x142a86f60> font-family: ".SFUI-Regular"; font-weight: normal; font-style: normal; font-size: 17.00pt
我在这里错过了什么吗?您是否无法将UIFont.preferredFont
NSAttributedString 中的字体另存为字体。我只是在加载时重新添加字体,但这不起作用,因为字符串的属性丢失了(粗体、斜体等)。
解决方案
推荐阅读
- javascript - jQuery 嵌套的 .parent() 方法不适用于动态元素,即使使用 .delegate()
- c# - 在c#中将所选项目作为当前项目
- javascript - 如何打破柏树块内的循环?
- botframework - Azure QnA Maker 跟进提示框大小
- docker - 为什么我看到 host.docker.internal 的两个不同值以及为什么 cassandra 容器无法绑定到它
- python-3.x - 如何使用python在文本文档的每一行中打印不同的单词?
- python - 将比较运算符分配给变量?
- vagrant - 如何修复未定义的流浪变量?
- sharepoint-online - SharePoint 反应 TextField onChanged 错误
- reactjs - 渲染大量组件实例时 React-select 导致加载缓慢