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
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
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!
If you're using a list, I'm pretty sure you can just use .scrollContentBackground(.hidden)
as a modifier to said list.