问题标签 [nsattributedstringkey]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
91 浏览

ios - Swift NSAttributedString.Key.foregroundColor 在某些较旧的 iOS 版本中不起作用

我在向 UILabel 文本添加多种颜色时使用了以下扩展名。结果在 iOS 13 及更高版本中按预期显示,虽然知道它会在 iOS 12.4 中导致问题,因为无论任何更改都显示默认 UILabel 文本颜色。

我最初也在使用属性初始化 ViewDidLoad() 中的 NSMutableAttributedString。想知道是什么原因导致它无法在较旧的 iOS 版本中运行。

0 投票
1 回答
75 浏览

ios - 如何更改 AttributedString 中 Markdown 样式文本的外观?

WWDC 2021在 Foundation 中引入了新的 AttributedString API ,包括对 Markdown 的支持。例如,我想更改通过降价创建的.stronglyEmphasized文本的外观AttributedString,以使强调文本的前景色为红色(以及粗体)。据我所知,它是这样的:

但这告诉我“没有上下文类型就无法解决对成员 'stronglyEmphasized' 的引用”和“无法推断通用参数 'U'”。这非常无益。