SwiftUI Text iOS15:文本视图中的电子邮件或 URL 使用强调色呈现

Eci*_*cil 15 swiftui swiftui-text ios15

在 iOS15 中运行以下代码时,内容中的 URL 或电子邮件地址的颜色使用强调色而不是前景色。我怎样才能覆盖它?

Text("Send a message to john@email.com to request support")
    .foregroundColor(.blue)
Run Code Online (Sandbox Code Playgroud)

iOS15 中文本视图是如何呈现的

ahe*_*eze 46

您可以按Text(verbatim:)原样呈现字符串,而不是自动从电子邮件创建链接。

Text(verbatim: "Send a message to john@email.com to request support")
    .foregroundColor(.blue)
Run Code Online (Sandbox Code Playgroud)

结果:

文字全是蓝色

如果需要,您还可以设置自己的强调色。

Text("Send a message to john@email.com to request support")
    .tint(.green)
Run Code Online (Sandbox Code Playgroud)

结果:

电子邮件为绿色,其余文本为黑色