Navigation Link Issue with SwiftUI

I have been using ScrollView with SwiftUI to develop a Custom Table Structure due to certain Customisation limitations with ListView. As soon I as I add NavigationLink for each item in scrollView. The icons or Images in the items are highlighted to blue color. Is this an already reported bug or is it something which I should avoid doing?

Accepted Reply

I have found that you can eliminate most of this by adding this after your NavigationLink:

.buttonStyle(.plain)

Replies

Looks like you are not the only one fstruggling with ScrollView in SwiftUI.


Did you see this, could it help ?


https://stackoverflow.com/questions/56534772/foreach-inside-scrollview-doesnt-take-whole-width

Hey Thanks there.


But I have been struggling with the specific "blue" highlighting of items in scroll view if embedded to a navigation Link and in rest cases it works fine. In navigation View, if navigation items are embedded into a button then again its the same issue.

Is it only in XCode or when running the app ?

I'm having the same issue here. No matter where it's running.

Just use .renderingMode(.original) modifier on your image

Hey this Image Instance is on SwiftUI and not with UIKit

This occurs with Preview also and also when I run the app on Simulator or Device

I have been trying to make a custom NavigationView that has a ScrollView inside,
just updated to beta 4, and am still having the same issue here.

All kinds of buttons(NavigationLink, PresentationLink—.sheet now instead—, Button, .navigationItems, ...) make any objects in itself blue(unless .foregroundColor is set differently, I guess).
It is very problematic for Images especially.
The workaround I am using currently is that I make the same-sized object, make that a button, and put that inside ZStack with the original one.


So, instead of this:


NavigationLink(destination: AView()){

Image("a")

.resizable()

.frame(width: 10.0, height: 10.0)

}


I write like this, for now:


ZStack{

Image("a")

.resizable()

NavigationLink(destination: AView()){

Rectangle()

.hidden() //or .opacity(0)

}

}

.frame(width: 10.0, height: 10.0)


Very ugly indeed.

Hope it will get fixed soon.

I have found that you can eliminate most of this by adding this after your NavigationLink:

.buttonStyle(.plain)

This should now be:

NavigationLink(destination: DetailView()) {
    MyView()
}.buttonStyle(PlainButtonStyle())

What happens here?

Hello!

I solved put It .buttonStyle(.plain)

at the the end of the NavigationLink like

`NavigationLink(destination : EmptyView()){

Text("Press here!")

}.buttonStyle(.plain) `