NSwippableCell 0.3.1

NSwippableCell 0.3.1

itisnajim 维护。



NSwippableCell

CI Status Version License Platform

描述

一个易于使用的 UICollectionViewCell 子类,它实现了可滑动内容视图,可以显示工具按钮或视图

预览

Preview Video

示例

Example Video

要运行示例项目,请先克隆仓库,然后在 Example 目录中运行 pod install

安装

NSwippableCell 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'NSwippableCell'

使用方法

1. 将单元格从NSwippableCell扩展而来

2. 添加右视图和/或左视图

let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as? NSwippableCell;

cell?.rightRevealView = // UIButton, UIImageView or any object extend from UIView
cell?.leftRevealView = // UIButton, UIImageView or any object extend from UIView

方法和属性

didRevealRightView

当右视图可见时的回调

cell?.didRevealRightView = { (isVisible: Bool) in
    print("The right view is visible: "+String(isVisible));
}

didRevealLeftView

当左视图可见时的回调

cell?.didRevealLeftView = { (isVisible: Bool) in
    print("The left view is visible: "+String(isVisible));
}

closeRevealedView

关闭/隐藏已揭示的视图

cell?.closeRevealedView(){
    print("The revealed view is closed");
}

hideRightRevealViewIfOtherOpened

当同一UICollectionView中的其他单元格打开(显示左或右视图)时,使单元格关闭/隐藏右视图

cell?.hideRightRevealViewIfOtherOpened = // true or false, default is true.

hideLeftRevealViewIfOtherOpened

当同一UICollectionView中的其他单元格打开(显示左或右视图)时,使单元格关闭/隐藏左视图

cell?.hideLeftRevealViewIfOtherOpened = // true or false, default is true.

doSwipe

程序化地滚动单元格向右或向左

cell?.doSwipe(gestureDirection: direction); // let direction: UISwipeGestureRecognizer.Direction = .right or .left

作者

itisnajim, [email protected]

许可

NSwippableCell可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。