Reputation: 1402
I have the folowing Text()
that takes markdown to show a link
Text(.init("[Link Example](https://www.google.es/)"))
Is there a way of changing the default color set to the link?
Upvotes: 21
Views: 10119
Reputation: 5729
Another solution using Link
(iOS 14+):
if let url = URL(string: "https://www.google.es/" {
Link(destination: url) {
Text("Link Example")
.foregroundColor(Color(.label))
}
}
Upvotes: 1
Reputation: 3394
Link color is the default accent color of the app which is blue.
You can change this by setting a custom accent color:
Add a color set in your Assets.xcassets
In target -> Build settings, search for "Global Accent Color Name"
Double click on it and set the color name aded in step 1
Thats it..!
Upvotes: 0
Reputation: 257653
It is possible to use accent color, like
Text(.init("[Link Example](https://www.google.es/)"))
.accentColor(.red)
Upvotes: 35
Reputation: 1879
You can achieve that with .tint(_:)
as accentColor(_:)
will soon be deprecated according to the documentation.
Text("[Link Example](https://www.google.es/)")
.tint(Color.red)
Upvotes: 21