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?
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?
It is possible to use accent color, like
Text(.init("[Link Example](https://www.google.es/)"))
.accentColor(.red)
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)
AttributedString
in Text
, and define the foregroundColor
on the range of the text where the link is added. Refer to this question –
Justinn Another solution using Link
(iOS 14+):
if let url = URL(string: "https://www.google.es/" {
Link(destination: url) {
Text("Link Example")
.foregroundColor(Color(.label))
}
}
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..!
© 2022 - 2025 — McMap. All rights reserved.