I would like to make "here" a button on this note. Anyone could you tell me how to do that?
CodePudding user response:
A possible approach is to use mark-down text with link and handle link by intercepting url.
Tested with Xcode 13.4 / iOS 15.5
Here is main part:
Text("All your information are confidential. For more information please refer to [here](conf_info)")
}
.environment(\.openURL, OpenURLAction { url in
if url == URL(string: "conf_info") { // << intercept key
showDetails()
return .handled
}
return .systemAction
})
CodePudding user response:
You can create a link in any Text
view using Markdown's standard syntax, e.g.
Text("...For more information refer to [our privacy policy](https://example.org/privacy)")
If your destination is a public URL then that is all you need to do – clicking on it will open the relevant page in Safari.
However, if you want the click to be handled inside your app, you will need to pass the text view a custom OpenURLAction
. See this answer to a previous question on how to start going about that.