Answers for "SwiftUI remove swipeactions"

1

swipe right to delete swiftui

struct SingleIsland {
    let name: String
}

struct ContentView: View {

    @State var islands = [
        SingleIsland(name: "Wangerooge"),
        SingleIsland(name: "Spiekeroog"),
        SingleIsland(name: "Langeoog")
    ]

    var body: some View {
        List {
            ForEach(islands.identified(by: \.name)) { island in
                Text(island.name)
            }.onDelete(perform: delete)
        }
    }

    private func delete(with indexSet: IndexSet) {
        indexSet.forEach ({ index in 
        	islands.remove(at: index) 
        })
    }
}
Posted by: Guest on March-15-2020

Code answers related to "SwiftUI remove swipeactions"

Code answers related to "Swift"

Browse Popular Code Answers by Language