【发布时间】:2021-10-05 14:52:57
【问题描述】:
我认为这是 iOS 15 beta 1 或 2 的错误,但从 beta 4 开始,我仍然看到这种行为,所以也许我做错了什么: 文本应该使用 Markdown 呈现 AttributedStrings。当直接 String 文字被传递到 Text 时,它似乎可以正确呈现,但当 AttributedString 是变量时则不会。我在做一些超级愚蠢的事情吗?
struct ContentView: View {
var text = AttributedString("**Hello**, `world`! Visit our [website](https://www.capitalone.com).")
var body: some View {
VStack {
Text("**Hello**, `world`! Visit our [website](https://www.capitalone.com).")
.padding()
Text(text)
.padding()
}
}
}
【问题讨论】:
-
试试我的
markdownToAttributed分机:stackoverflow.com/a/67888726/14351818 -
注意:“我的答案”完全是@aheze 的作品。