When I use a link within a text like this:
Text("https://www.youtube.com")
As expected, the link shows up and I can press it and go to YouTube.
However, when I declare a variable first:
@State var link: String = "https://www.youtube.com"
// ...
Text(link)
The text is black and I can’t press it to navigate to YouTube.
How can I make this text tappable as well, without using a link or url?
>Solution :
The difference is LocalizedStringKey which is the default for a Text which you are setting as a String in your @State.
You have to convert in one of 2 ways
At the @State level
@State var link: LocalizedStringKey = "https://www.youtube.com"
or in the body
Text(LocalizedStringKey(link))
Whichever is best is up to you, likely option 2.