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      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.