在 Swift 中,可以使用 NSMutableAttributedString
在文本中嵌入链接,例如此处所示的链接。
那么,在 SwiftUI
中要如何实现相同的效果呢?
我尝试了以下代码,但它并不符合我的期望:。
import SwiftUI
struct ContentView: View {
var body: some View {
HStack {
Text("By tapping Done, you agree to the ")
Button(action: {}) {
Text("privacy policy")
}
Text(" and ")
Button(action: {}) {
Text("terms of service")
}
Text(" .")
}
}
}