I've seen people using AttributedString and .link to link to something, but I need it to run a function, not open a browser link. I want something like this in SwiftUI, with wrapping, etc. Terms of service agreement (this image was made with HTML)
I tried buttons, but that results in
HStack {
Text("By clicking continue you agree to our ")
Button("Terms Of Service") {}
Text(" and our ")
Button("Privacy Policy") {}
}
Awful Looking TOS notification:

Just use Text
struct ContentView: View {
@State var text: String = ""
@State var textTapped: String = ""
var body: some View {
VStack {
HStack(spacing: 0){
Text("Just text ")
Text("tap me").onTapGesture {
tapped()
}
Text(" some more text")
}
Text(textTapped)
}
}
func tapped() {
textTapped = "was tapped"
}
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With