FMSwipify
概览
一个旨在使处理嵌套 Collection Views 的工作更加容易的框架。该框架还为您自己的自定义实现提供良好的基础。
使用
- 控制器
import UIKit
import FMSwipify
class ViewController: SwipifyController<YourCell, YourModel> {
override var cellSource: CellSource { return .nib }
override var cellSize: CGSize { return CGSize(width: collectionView.frame.width, height: 350)}
override var data: [[Post]] { return DataStore.store.posts }
let config = Config(
sectionTitleFont: .systemFont(ofSize: 16, weight: .medium),
sectionsIcon: DataStore.store.icons,
sectionIconSize: .init(width: 30, height: 30),
sectionsBackgroundColor: .red,
sectionsSelectedColor: .white,
sectionsUnselectedColor: UIColor(white: 0, alpha: 0.6),
sectionsSelectorColor: .white,
sectionSelectorType: .bar
)
override func viewDidLoad() {
super.viewDidLoad()
setConfig(config)
}
}
- 单元
import FMSwipify
class YourCell: SwipifyBaseCell<YourModel> {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var subTitleLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
guard let yourModel = item else {return}
titleLabel.text = yourModel.title
subTitleLabel.text = yourModel.subTitle
}
}
- 模型
struct YourModel {
let title: String
let subTitle: String
}
配置 API
*
-- 必须定义
属性 | 描述 | 默认值 |
---|---|---|
sectionsTitle | 设置每个部分的标题 | 空 |
sectionTitleFont | 设置部分标题的字体 | systemFont(ofSize: 15, weight: .regular) |
sectionsIcon | 设置每个部分的图标 | 空 |
sectionIconSize | 设置您部分图标的大小 | CGSize(width: 30, height: 30) |
sectionsBackgroundColor | 设置部分横幅的背景 | 白色 |
sectionsSelectedColor | 设置部分选择状态的颜色 | .black |
sectionsUnselectedColor | 设置部分未选中状态的颜色 | .lightGray |
sectionsSelectorColor | 设置选择器颜色 | .black |
sectionSelectorType | 指定选择器是条形还是气泡 | .bar |
cellSource | 指定单元格是否来自nib或代码 | .nib |
* cellSize | 设置单元格大小 | .zero |
需求
Swift 4.0+ 和 iOS 9.0+
安装
FMSwipify可以通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中
pod 'FMSwipify'
作者
FranckNdame, [email protected] Ahmad Karkouti, [email protected]
贡献
欢迎提交Fork、补丁和其他反馈。
开发
此库目前仍处于早期开发阶段,目前正在开发更多功能和想法。
许可
FMSwipify遵循MIT许可。有关更多信息,请参阅LICENSE文件。