测试已测试 | ✗ |
语语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2017 年 7 月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 pikachu987 维护。
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
import PKCSwipeReusableView
class ReusableView: PKCSwipeReusableView{ }
class ViewController: UIViewController{
override func viewDidLoad(){
self.collectionView.register(ReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "ReusableView")
self.collectionView.dataSource = self
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionElementKindSectionHeader{
let reusableView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "ReusableView", for: indexPath) as! ReusableView
reusableView.label.text = "ReusableView Header"
let pkcButton1 = PKCButton(frame: .zero)
pkcButton1.backgroundColor = .red
pkcButton1.setTitle("Delete", for: .normal)
reusableView.addRightSwipe(pkcButton1)
pkcButton1.addTarget({ (button) in
print(button)
})
if indexPath.section < 3{
let pkcButton2 = PKCButton(frame: .zero)
pkcButton2.backgroundColor = .green
pkcButton2.setTitle("Save", for: .normal)
reusableView.addLeftSwipe(pkcButton2)
}
return reusableView
}else{
assert(false, "Unexpected element kind")
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: UIScreen.main.bounds.width, height: 50)
}
}
PKCSwipeReusableView 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile:
pod "PKCSwipeReusableView"
pikachu987, [email protected]
PKCSwipeReusableView 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。