Remove SwiftUI NavigationLink arrow when in a List

90 Views Asked by At

I currently have a view like this:

current view setup with button

The blue icon is currently a Button which is set to show a sheet. I want to change this sheet to a completely separate view, so I understand I will need to change the Button to a NavigationLink

The code for this is:

List {
    Section {
        HStack {
            TextField("Name", text: $item.name)
            Button(action: {
                isPresentingScanner = true
            }, label: {
                Image(systemName: "barcode.viewfinder")
            })
        }
    } header: {
        Text("Name")
    } footer: {
        Text("Click the icon to scan a product barcode")
    }
}

However when I change this to a NavigationView, the formatting gets messed up. The arrow icon appears (which I do not want) and the icon gets moved to a more central position.

view setup with navigationview

The code for this is:

List {
        Section {
            HStack {
                TextField("Name", text: $item.name)
                NavigationLink(destination: Text("Example View")) {
                    Image(systemName: "barcode.viewfinder")
                }
            }
        } header: {
            Text("Name")
        } footer: {
            Text("Click the icon to scan a product barcode")
        }
    }

Any suggestions on how to achieve the look of the first picture example, but the functionality of a NavigationView (i.e. being able to push to a new view) would be greatly appreciated.

Thanks.

0

There are 0 best solutions below