Adding Swipe Actions to UITableViewCells | Swift 5, XCode 15

Поділитися
Вставка
  • Опубліковано 21 січ 2025

КОМЕНТАРІ • 3

  • @titochicoma4299
    @titochicoma4299 8 місяців тому

    Just what i was looking for!! amazing!! when you delete the cell, How do you make it disappear with animation?

    • @SoftwareDevelopment13
      @SoftwareDevelopment13  8 місяців тому +1

      For the swipe action you use the UIContextualAction in this animation is default.
      Here are example
      Following code you need to write in UITableView delegate method.
      Delegate method name: trailingSwipeActionsConfigurationForRowAt
      let action = UIContextualAction(style: .destructive, title: nil) { (action, view, completion) in
      print("Delete action")
      completion(true) // Handle completion after performing action
      }
      action.backgroundColor = ColorManager.primaryColor
      action.image = UIImage(named: ImageManager.icon_delete)
      // Create swipe actions configuration
      let swipeConfig = UISwipeActionsConfiguration(actions: [action])
      swipeConfig.performsFirstActionWithFullSwipe = false
      return swipeConfig

    • @titochicoma4299
      @titochicoma4299 8 місяців тому +1

      @@SoftwareDevelopment13 Thanks you!!!