Post

Replies

Boosts

Views

Activity

SwiftUI List with Selection is Highlighting even in non-edit mode
I recently updated my xcode and compiled my application developed in SwiftUI. The SwiftUI List started to behave different. List has Selection parameter for EditMode selection. However, now the list items are being selected and highlighted with grey highlighted color, even in a non-edit default mode. Ideally, it should only select the list item in edit mode. It is how it worked before. But now when the list item is tapped in non-edit mode, it is getting selected. Please, let me know how to make list with selection to highlight only in editmode. import SwiftUI struct ContentView: View {       struct Ocean: Identifiable, Hashable {     let name: String     let id = UUID()   }   private var oceans = [     Ocean(name: "Pacific"),     Ocean(name: "Atlantic")   ]       @State private var multiSelection = Set<UUID>()       var body: some View {           NavigationView {       VStack {                   List(oceans, selection: $multiSelection) { ocean in           Text(ocean.name)         }         .toolbar { EditButton() }       }       .padding()       .buttonStyle(PlainButtonStyle())     }   } }
5
1
3.7k
Sep ’22