Post

Replies

Boosts

Views

Activity

Reply to onDelete change label
Tested @OOPer answer, and it works well. However, let say you are building a language App and need to change "Delete" for a selected language dynamically. I've tried the following test code, but that does not work. How can the language be change in code? struct ContentView: View { @State var items = ["item 1","item 2","item 3"] var body: some View { List() { ForEach(0 .. items.count) { Text(items[$0]) }.onDelete(perform: deleteTasks) } .environment(\.locale, Locale(identifier: "ja")) // -- try to change the language } } func deleteTasks(offsets: IndexSet) { }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21