Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI NavigationLink Hide Arrow

Tags:

Is there a way to hide the arrow to the right of the navigation link view that is automatically added?

I want to show an image grid using NavigationView -> List -> HStack -> NavigationLink_1 - NavigationLink_2

The NavigationLinks have arrows and it looks weird enter image description here

like image 981
blackops Avatar asked Oct 11 '19 02:10

blackops


People also ask

How do I hide navigation arrows in SwiftUI?

opacity(0.0) to hide the arrow.

How do I hide disclosure indicator SwiftUI?

For the navigation link, instead of presenting the Text view, we change it to display an empty view. And, we attach the opacity modifier to NavigationLink and set its value to 0 . If you test the change in the preview, the disclosure indicator should disappear.

How do I hide the navigation bar back button in SwiftUI?

The . navigationBarBackButtonHidden(true) will hide the back button.

How do I manage navigation in SwiftUI?

SwiftUI's NavigationLink has a second initializer that has an isActive parameter, allowing us to read or write whether the navigation link is currently active. In practical terms, this means we can programmatically trigger the activation of a navigation link by setting whatever state it's watching to true.


2 Answers

The way it worked for me:

List {      ForEach(elements) { element in         ZStack {             CustomView(element: element)             NavigationLink(destination: DestinationView()) {                 EmptyView()             }.buttonStyle(PlainButtonStyle())         }     } } 
like image 108
Vladimirs Matusevics Avatar answered Nov 04 '22 01:11

Vladimirs Matusevics


I got it done with this

NavigationLink(destination: DestinationView()) {       EmptyView() } .frame(width: 0, height: 0) .hidden() 
like image 43
Jagoan Neon Avatar answered Nov 04 '22 01:11

Jagoan Neon