CSSegmentView 版本 1.1.0

CSSegmentView 版本 1.1.0

测试测试通过
语言语言 Obj-CObjective C
许可证 MIT
发布日期最后发布日期2016年5月

cbsfly 维护。



CSSegmentView 版本 1.1.0

  • 作者:
  • cbsfly

效果

wait

wait

使用

初始化

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置各个标签名字
    self.cbs_titleArray = @[@"first", @"second", @"third", @"first", @"second", @"third"];
    //设置各个标签对应的ViewController,如果数量不对会崩溃
    self.cbs_viewArray = @[@"FirstViewController", @"SecondViewController", @"ThirdViewController", @"FirstViewController", @"SecondViewController", @"ThirdViewController"];
    self.cbs_Type = CBSSegmentHeaderTypeScroll;
    //先设置cbs_titleArray和cbs_viewArray再调用initSegment
    [self initSegment];
}

type 有两种类型

typedef NS_ENUM(NSInteger, CBSSegmentHeaderType) {
    CBSSegmentHeaderTypeScroll,//标签栏可滚动
    CBSSegmentHeaderTypeFixed//标签栏固定
};

设置(在初始化前设置)

//标签栏颜色,默认白色
@property (nonatomic, strong) UIColor *cbs_headerColor;

//非选中状态下标签字体颜色,默认黑色
@property (nonatomic, strong) UIColor *cbs_titleColor;

//选中标签字体颜色,默认蓝色
@property (nonatomic, strong) UIColor *cbs_titleSelectedColor;

//选中标签底部划线颜色,默认蓝色
@property (nonatomic, strong) UIColor *cbs_bottomLineColor;

//segmentView背景色,默认透明
@property (nonatomic, strong) UIColor *cbs_backgroundColor;

//标签栏高度
@property (nonatomic, assign) CGFloat cbs_buttonHeight;

//标签栏每个按钮宽度
@property (nonatomic, assign) CGFloat cbs_buttonWidth;

//选中视图下划线高度,置零可取消下划线
@property (nonatomic, assign) CGFloat cbs_lineHeight;

//标签栏类型,默认为滚动标签栏
@property (nonatomic, assign) CBSSegmentHeaderType cbs_Type;

按钮点击动作

- (void)didSelectSegmentIndex:(NSInteger)index;

自己编写的部分源码解析点这里

如果有所帮助,希望可以star一下,欢迎留言反馈意见,我将进行改进。