Post

Replies

Boosts

Views

Activity

Using an AttributedString link to open a view
I want to use a SwiftUI TextField with an AttributedString where if you click on a link within the AttributedString it opens another view within the same app and passes parameters to it. E.g. you are within a text adventure. The AttributedString is "You stand at a crossroads. You can walk [north] or [south]", where the words north and south are each styled as a link and clicking on them opens another view that gets passed the parameter of which place you have chosen. What is the "correct" way to do this? I imagine I could define lots of CustomURLs that do this but that seems like a hacky approach as it would be exposed outside the app. I really just want to link back and forth between views within my app.
6
0
3.0k
Jun ’21