I need to change the title of all the navigationlink
s to a different color other than blue, like a custom green. Don't know where to begin.
Asked
Active
Viewed 872 times
3

Scotty
- 39
- 6
-
@ThomasMartin not quite. But I'll see if I can adapt it for `navigationlink` to my project. I'll report back if I do. – Scotty Mar 13 '20 at 06:14
1 Answers
4
Use accent color like the following
NavigationView {
// content here
}.accentColor(Color.green)

Asperi
- 228,894
- 20
- 464
- 690
-
Thank you. Is there a way to declare this value once to take effect across the app? – Scotty Mar 13 '20 at 06:20
-
@Scotty, accentColor is applied for all subviews, so just apply it for `ContentView` in `SceneDelegate` or use there `tintColor` applied directly to `UIWindow`. Also you can check [this](https://stackoverflow.com/a/60381525/12299030) topic. – Asperi Mar 13 '20 at 06:29
-
I'm getting an error at `@Environment(\.hostingWindow) var hostingWindow`. Error reads `Type of expression is ambiguous without more context` – Scotty Mar 13 '20 at 08:04
-
@Scotty, have you set up `hostingWindow` as specified by the link provided at the top of that answer? – Asperi Mar 13 '20 at 08:57
-
I've tried piecing the different answers you've given on the topic and no luck. – Scotty Mar 13 '20 at 22:35
-
Could you host your demo from https://stackoverflow.com/questions/60368765/how-to-change-tintcolor-of-whole-app-swiftui?answertab=active#tab-top on github? – Scotty Mar 13 '20 at 22:47
-