BWSwipeRevealCell 3.0.0

BWSwipeRevealCell 3.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2019年4月
SPM支持 SPM

Kyle Newsome 维护。



BWSwipeRevealCell

Example

使用库

**注意:使用 1.0.1 版本支持 Swift 2.3,使用 2.0.0 或更高版本支持 Swift 3**

有两大主要类可用 - BWSwipeCellBWSwipeRevealCell

BWSwipeCell - 只包含滑动手势处理,主要适用于通过子类化大量自定义,如果您只需要提高滑动交互能力

BWSwipeRevealCell - 是一个现成的解决方案,允许您为表格单元的左右两侧设置图像和颜色。BWSwipeRevealCell 是 BWSwipeCell 的子类。

BWSwipeRevealCell 示例

设置 BWSwipeRevealCell 为您的表格单元类型并在 storyboard 中设置一个代理后,在控制器中使用此代码

    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! BWSwipeRevealCell
        
        swipeCell.bgViewLeftImage = UIImage(named:"Done")!.withRenderingMode(.alwaysTemplate)
        swipeCell.bgViewLeftColor = UIColor.green
        
        swipeCell.bgViewRightImage = UIImage(named:"Delete")!.withRenderingMode(.alwaysTemplate)
        swipeCell.bgViewRightColor = UIColor.red
        
        swipeCell.type = .springRelease
        
        swipeCell.delegate = self // Or whatever your delegate might be
        return cell
    }

通过界面自定义

BWSwipeCell 属性

var type: BWSwipeCellType

可以是 .springRelease, .swipeThrough.slidingDoor。默认为 .springRelease

var revealDirection: BWSwipeCellRevealDirection

可以是 .both, .left.right。默认为 .both

(只读) var state: BWSwipeCellState

可以是 .normal, .pastThresholdLeft.pastThresholdRight

var threshold: CGFloat

触摸弹性开始点,以及 state 变化的点。默认为 UITableViewCell 的高度(即,当它形成一个完美的正方形时)

(只读) var progress:CGFloat

一个介于 0 和 1 之间的数字,表示当前滑动方向达到阈值的进度。当用户滑动时,有助于逐步更改 UI。

var shouldExceedThreshold: Bool

控制细胞是否越过阈值点

var panElasticityFactor: CGFloat

控制越过阈值后有多少弹性,如果可以越过。默认值为 0.7,而 1.0 则表示没有弹性阻力

var animationDuration: Double

动画持续时间。默认为 0.2

weak var delegate: BWSwipeCellDelegate?

在细胞上设置委托

@objc public protocol BWSwipeCellDelegate: NSObjectProtocol {
    optional func swipeCellDidStartSwiping(cell: BWSwipeCell)
    optional func swipeCellDidSwipe(cell: BWSwipeCell)
    optional func swipeCellWillRelease(cell: BWSwipeCell)
    optional func swipeCellDidCompleteRelease(cell: BWSwipeCell)
    optional func swipeCellDidChangeState(cell: BWSwipeCell)
}

BWSwipeRevealCell 属性

var bgViewInactiveColor: UIColor

var bgViewLeftColor: UIColor

var bgViewRightColor: UIColor

用于非活动和激活状态的左和右的颜色

var bgViewLeftImage: UIImage?

var bgViewRightImage: UIImage?

左和右动作的图片

weak var delegate: BWSwipeRevealCellDelegate?

@objc public protocol BWSwipeRevealCellDelegate:BWSwipeCellDelegate {
    optional func swipeCellActivatedAction(cell: BWSwipeCell, isActionLeft: Bool)
}

在细胞上设置委托

路线图

关于改进此库的一些简要思路

v 1.x.0 (Swift 2.x 版本)

  • 已完成
v 2.x.0 (Swift 3.x版本)
  • 修复bug
v 3.0.0
v x.0.0(即想法。欢迎PR。)
  • 每侧可自定义交互(例如,左侧.SwipeThrough,右侧.SlidingDoor)
  • 可能的子类,允许.SlidingDoor超过阈值点转换为.SwipeThrough(参见Mail.app)