Reputation:
I have list items in SwiftUI and when I click the list items it stay in gray color when I back to list view menu. Is there any solution?
DarkMenuView:
struct DarkMenuView: View {
@AppStorage("isDarkMode") private var isDarkMode = false
var body: some View {
VStack{
Picker("Mode" , selection: $isDarkMode) {
Text("Light")
.tag(false)
Text("Dark")
.tag(true)
}.pickerStyle(SegmentedPickerStyle())
.padding()
List(0..<5, id: \.self) { num in
NavigationLink(destination: Text("\(num)")) {
Text("\(num)")
}
}
}.navigationTitle("Dark Menu")
.onAppear() {
print("DarkMenuView.onAppear()")
}
}
}
screenshot:
Upvotes: 2
Views: 601
Reputation: 956
You can achieve this by making selection style None
.onAppear {
UITableViewCell.appearance().selectionStyle = .none
}
Upvotes: 0
Reputation: 36617
Works well in ios-15. You could try adding ".isDetailLink(false)" to the NavigationLinks.
Upvotes: 1