UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Is there a way to style the navigation link?

Forums > SwiftUI

I am trying to style the navigation Link button in SwiftUI right now it's the standard blue but I am trying to get it to Black and Bold similar to that of Fitness+ but the problem I encounter based on all the research I have done is finding a solution to the problem.

I hope someone can guide me.

Best, Imran

1      

Not sure what you want but add .modifliers to want you want.

struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink {
                Text("New View")
            } label: {
                Text("Tapped Me")
            }
            .padding()
            .background(.black)
            .foregroundColor(.white)
            .font(.headline)
            .cornerRadius(10)
        }
    }
}

.buttonStyle also works

struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink {
                Text("New View")
            } label: {
                Text("Tapped Me")
            }
            .buttonStyle(.borderedProminent)
        }
    }
}

1      

I am trying to change the colour of the nagivation link text. For example, on fitness+ if you click HIIT the back button is black, how do you do that on the navigation link? These modifiers don't change the colour of my navigation link it's still blue.

1      

Using

.accentColour(Color.black) 

on the navigation view is what made the navigation link black.

1      

Sorry You want the Colors in the Navigation Bar to be different color.

Then goto to the Asserts file and you will see AccentColor change this to the color you want in App struct use .tint(.accentColor). See below

@main
struct TestApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .tint(.accentColor)
        }
    }
}

PS .accentColour has been depreciated.

1      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.