测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017 年 10 月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 zswangzP105318 维护。
##该框架的主要功能包括两部分
####集成该框架的主要步骤
import ZPSegmentBar
ZPStyle
,并且传入我们需要的样式,例如var style = ZPStyle()
style.isScrollEnabled=true; //标题是否可以滚动,默认为true;
style.isShowCover = true //标题是否显示遮盖,默认为true;
style.isShowBottomLine=true //标题下方是否显示BottomLine,默认为true;
style.isNeedScale=true //标题文字是否缩放,默认为true;
.
.
.
ZPSegmentBarView
,并且传入所需要的参数let segmentView = ZPSegmentBarView(frame: frame, titles: titles, style: style, childVcs: childVcs, parentVc: self)
ZPSegmentBarView
添加到当前View中即可view.addSubview(segmentView)
####集成该功能的主要步骤
import ZPSegmentBar
ZPStyle
,并且传入我们需要的样式,例如var style = ZPStyle()
style.isScrollEnabled=false; //标题是否可以滚动,默认为true;
style.isShowCover = false //标题是否显示遮盖,默认为true;
style.isShowBottomLine=true //标题下方是否显示BottomLine,默认为true;
style.isNeedScale=true //标题文字是否缩放,默认为true;
.
.
.
ZPPageBarLayout
布局,并且传入我们需要的样式,例如let layout = ZPPageBarLayout()
layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
layout.minimumLineSpacing=10 //行距
layout.minimumInteritemSpacing=10 //item之间的间距
layout.columns=8 //列数
layout.rows = 3 //行数
ZPPageBarView
,并且传入我们需要的参数,设置数据源代理,注册celllet pageBarView = ZPPageBarView(frame: frame, titles: titles, style: style, layout: layout)
pageBarView.dataSource=self //设置数据源代理,并且实现数据源方法
pageBarView.registerCell(UICollectionViewCell.self, reusableIdentifier: kCollectionViewCellID)
view.addSubview(pageBarView)
extension ViewController : ZPPageBarViewDataSource
{
func numberOfSections(in pageBarView: ZPPageBarView) -> Int {
return 4
}
func pageBarView(_ pageBarView: ZPPageBarView, numberOfItemsInSection section: Int) -> Int {
if section == 0 {
return 61
} else if section == 1 {
return 18
} else if section == 2 {
return 40
} else {
return 18
}
}
func pageBarView(_ pageBarView: ZPPageBarView, collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCollectionViewCellID, for: indexPath)
cell.backgroundColor = UIColor.randomColor()
return cell
}
}
如果是导航控制器,我们需要在集成的View中 设置 automaticallyAdjustsScrollViewInsets=false
ZPSegmentBar 通过 CocoaPods 提供。要安装
它,简单地添加以下行到您的 Podfile 中
pod 'ZPSegmentBar', '~> 0.1.5'
gzp, [email protected]
ZPSegmentBar 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。