How to take off background from NavigationLink items.

Hey guys,

I was using a ForEach loop and everything was fine. But when I implement NavigationLink, the background of each item turned gray. Any ideas on how to remove the background?

Please answer as fast as possible.

Much appreciated, mrhn_huor

Answered by Blackhole1123 in 750382022

If you're using a list, I'm pretty sure you can just use .scrollContentBackground(.hidden) as a modifier to said list.

Hi there!

Whenever we would like to use NavigationLink, we need to wrap it around NavigationView. In this way, the gray / disabled background will be gone!

NavigationView {
    List { 
        ForEach(1..<6) { i in
            NavigationLink("\(i)") { 
                Text("\(i)");
            }
        }
    }
}

Good luck!

Accepted Answer

If you're using a list, I'm pretty sure you can just use .scrollContentBackground(.hidden) as a modifier to said list.

How to take off background from NavigationLink items.
 
 
Q