Hello fellow developers,
I'm working with a NavigationSplitView in my SwiftUI application and encountering a challenge. In my app, a specific destination view (WalkView) is loaded by default at startup. I would like to have the corresponding NavigationLink in my NavigationSplitView appear as selected or active to reflect this (with the accentColor).
Is there a way to programmatically set a NavigationLink as selected by default within a NavigationSplitView when the app launches?
I found the isActive, but that one is deprecated. https://developer.apple.com/documentation/swiftui/navigationlink/init(_:destination:isactive:)-3v44
Any insights or guidance on achieving this behavior would be greatly appreciated.
NavigationSplitView {
List {
NavigationLink(
destination: WalkView()
) {
Label("Walk", systemImage: "figure.walk")
}
NavigationLink(
destination: SoccerView()
) {
Label("Soccer", systemImage: "figure.soccer")
}
}
} detail: {
// start-up view
WalkView()
}
.edgesIgnoringSafeArea(.top)
.accentColor(Color.blue) // my accent color, I want Walk to be blue at start-up