Swipeable UITableViewCell based on the stock Mail.app, implemented in Swift.
A swipeable UITableViewCell with support for:
The transition style describes how the action buttons are exposed during the swipe.
The expansion style describes the behavior when the cell is swiped past a defined threshold.
use_frameworks! # Latest release in CocoaPods pod 'SwipeCellKit' # Get the latest on develop pod 'SwipeCellKit', :git => 'https://github.com/jerkoch/SwipeCellKit.git', :branch => 'develop'
github "jerkoch/SwipeCellKit"
Read the docs . Generated with jazzy . Hosted by GitHub Pages .
Set the delegate property on SwipeTableViewCell :
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! SwipeTableViewCell
cell.delegate = self
return cell
}
Adopt the SwipeTableViewCellDelegate protocol:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
guard orientation == .right else { return nil }
let deleteAction = SwipeAction(style: .destructive, title: "Delete") { action, indexPath in
// handle action by updating model with deletion
}
// customize the action appearance
deleteAction.image = UIImage(named: "delete")
return [deleteAction]
}
Optionally, you call implement the options method to customize the behavior of the swipe actions:
func tableView(_ tableView: UITableView, editActionsOptionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> SwipeTableOptions {
var options = SwipeTableOptions()
options.expansionStyle = .destructive
options.transitionStyle = .border
return options
}
Created and maintained by @jerkoch .
SwipeCellKit is released under an MIT License . See LICENSE for details.
Please provide attribution, it is greatly appreciated.