Swift版本
ZPSegmentBarOC 该框架分为OC和Swift两个版本:点击前往模仿今日头条或者是网易新闻 NavigationBar 效果,效果图如下
集成该框架步骤
ZPSegmentView
头文件: #import "ZPSegmentView.h"
1. 导入ZPSegmentBarStyle
,并且传入我们需要的样式,例如
2. 实例化ZPSegmentBarStyle * style=[[ZPSegmentBarStyle alloc] init];
style.isScrollEnabled=YES;//导航条是否可以滚动,默认YES;
style.isShowCover=YES;//导航条是否显示遮盖效果,默认YES;
style.coverViewMargin=6;//遮盖间距;
style.isShowBottomLine=YES;//导航条下方是否显示BottomLine,默认YES;
style.bottomLineColor=[UIColor orangeColor];//BottomLine 的颜色;
style.isNeedScale=YES;//导航条是否有放大效果,默认YES;
style.titleViewBG=[UIColor purpleColor];//导航条背景颜色,默认为紫色;
...
...
...
通过配置我们需要的样式可以轻松的实现遮盖
文字缩放
下划线
文字颜色变化
等样式.
ZPSegmentView
并传入所需的参数
3. 实例化 ZPSegmentView * segmentView=[[ZPSegmentView alloc]initWithFrame:frame];
[segmentView setupWithtitles:titles style:style childVcs:childVcs parentVc:self];
ZPSegmentView
添加到当前 View
中即可
4. 将创建好的 [self.view addSubview:segmentView];
注意
如果是导航控制器,我们需要在集成的 View
中设置 [self setAutomaticallyAdjustsScrollViewInsets:NO];
安装
ZPSegmentBarOC 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ZPSegmentBarOC', '~> 0.2.0'
作者
[email protected],[email protected]
许可
ZPSegmentBarOC 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。