iOS開源-SwipeCellKit:UITableViewCell 內各種滑動變化及動畫效果

Jolene71D 7年前發布 | 14K 次閱讀 iOS開發 移動開發 UITableViewCell

SwipeCellKit

Swipeable UITableViewCell based on the stock Mail.app, implemented in Swift.

About

A swipeable UITableViewCell with support for:

  • Left and right swipe actions
  • Action buttons with: text only, text + image, image only
  • Haptic Feedback
  • Customizable transitions: Border, Drag, and Reveal
  • Animated expansion when dragging past threshold

Demo

Transition Styles

The transition style describes how the action buttons are exposed during the swipe.

Border

Drag

Reveal

Expansion Styles

The expansion style describes the behavior when the cell is swiped past a defined threshold.

None

Selection

Destructive

Requirements

  • Swift 3.0
  • Xcode 8
  • iOS 10.0+

Installation

CocoaPods (recommended)

use_frameworks!

Latest release in CocoaPods

pod 'SwipeCellKit'

Get the latest on develop

pod 'SwipeCellKit', :git => 'Carthage

github "jerkoch/SwipeCellKit"

Documentation

Read the docs . Generated with jazzy . Hosted by GitHub Pages .

Usage

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]

}</pre>

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
}

Credits

Created and maintained by @jerkoch .

License

SwipeCellKit is released under an MIT License . See LICENSE for details.

Please provide attribution, it is greatly appreciated.

 

 本文由用戶 Jolene71D 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!