Post

Replies

Boosts

Views

Activity

Show `swipeActions` in `editMode`
I have a List in a NavigationStack and the list items have swipeActions struct ListItem: Identifiable { var id: String { return name } let name: String } struct ContentView: View { @Environment(\.editMode) var editMode @State var listItems = [ ListItem(name: "Cow"), ListItem(name: "Duck"), ListItem(name: "Chicken") ] var body: some View { NavigationStack { List(listItems) { listItem in NavigationLink { Text(listItem.name) } label: { Text(listItem.name) } .swipeActions(edge: .trailing) { Button(action: { }, label: { Text("Edit") }).tint(.blue) Button(role: .destructive, action: {}, label: { Text("Delete") }) } } .navigationTitle("Animals") .navigationBarItems(trailing: EditButton()) } } } For users who might have problems with the swipe gesture, I would like to have the Swipe Actions display when the list is in editMode. Is there a programmatic way to show the swipeActions? I have also tried using ForEach with an onDelete modifier. Then if you hit the edit button, it shows a circular button on the left for each row. If you click the circular button then it will show the swipe actions but I don't want the extra step of pressing the circular button.
1
0
338
Jun ’24
`NSValue` containing an `NSAffineTransform` from Swift
In trying to create a CIAffineTransform filter on MacOS X you are supposed to encode an NSAffineTransform using Objective-C code like: [NSValue valueWithBytes:&xform objCType:@encode(NSAffineTransform)]; But in Swift the Objective-C @encode directive does not exist in Swift. How do you encode an NSAffineTransform into an NSValue in Swift so that it will be acceptable to Core Image?
1
0
866
Jan ’23