ios – SwiftUI Navigation Link Selection’s Highlight Not Working


In iOS, when you tap a row in a list to navigation to a page, the row gets highlighted to indicate which row is selected. This is not working for me when I have a NavigationStack(path:root:) that uses NavigationLink(_ titleKey:value:) and navigationDestination(for:destination).

Highlight doesn’t work in the code below for me neither in Simulator nor device:

import SwiftUI

struct ExperimentView: View {
    @State private var path = NavigationPath()

    var body: some View {
        NavigationStack(path: $path) {
            List {
                NavigationLink("Page", value: 0)
                NavigationLink("Page", value: 1)
                NavigationLink("Page", value: 2)
            }
            .navigationTitle("List")
            .navigationDestination(for: Int.self) { int in
                Text(int.description)
            }
        }
    }
}

But it works just fine when I use NavigationStack(root:) that uses NavigationLink(_ titleKey:destination).

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img