Latest 1.3.1
Homepage https://github.com/captain9911/CAPSegment
License MIT
Platforms ios 7.0, requires ARC
Authors

分段选择,每页可由同一个ViewController控制,也可由不同的ViewController分别控制。

Demo截图

image
image
image
image
image
image
image
image
image
image
image
image
image

代码集成

CocoaPods集成方式

在工程的Podfile里添加以下代码:

pod ‘CAPSegment’

保存并执行 pod install,然后用后缀为_.xcworkspace_的文件打开工程。

关于CocoaPods的更多信息请查看CocoaPods官方网站

手动集成方式

向工程中导入CAPSegment下的 CAPSegmentViewController.h 和 CAPSegmentViewController.m

快速使用

所有页面使用同一个ViewController控制

    NSArray *titleArray = @[@"标题1", @"标题2", @"标题3", @"标题4", @"标题5", @"标题6"];
    //ViewController类名
    NSString *subVCName = @"TestViewControllerOne";
    CAPSegmentViewController *segmentVC = [[CAPSegmentViewController alloc] initWithTitleArray:titleArray subViewControllerName:subVCName];
    segmentVC.pageTitle = @"统一控制";
//    segmentVC.titleWidth = 80;    //修改segment标题宽度
//    segmentVC.titleHeight = 60;   //修改segment标题高度
//    segmentVC.titleDefaultColor = [UIColor greenColor];   //修改segment标题默认颜色
//    segmentVC.titleSelectedColor = [UIColor redColor];    //修改segment标题选中后的颜色
//    segmentVC.displayCount = 5;                           //修改segment标题显示的数量
//    segmentVC.lineColor = [UIColor blueColor];            //修改segment标题与内容的分割线颜色
    [self.navigationController pushViewController:segmentVC animated:YES];

不同页面使用不同ViewController分别控制

    NSArray *titleArray = @[@"标题1", @"标题2", @"标题3", @"标题4", @"标题5", @"标题6"];
    //ViewController类名
    NSArray *subVCNameArray = @[@"TestViewControllerOne", @"TestViewControllerTwo",
                                @"TestViewControllerThree", @"TestViewControllerFour",
                                @"TestViewControllerFive", @"TestViewControllerSix"];
    CAPSegmentViewController *segmentVC = [[CAPSegmentViewController alloc] initWithTitleArray:titleArray subViewControllerNameArray:subVCNameArray];
    segmentVC.pageTitle = @"分别控制";
//    segmentVC.titleWidth = 80;    //修改segment标题宽度
//    segmentVC.titleHeight = 60;   //修改segment标题高度
//    segmentVC.titleDefaultColor = [UIColor greenColor];   //修改segment标题默认颜色
//    segmentVC.titleSelectedColor = [UIColor redColor];    //修改segment标题选中后的颜色
//    segmentVC.displayCount = 5;                           //修改segment标题显示的数量
//    segmentVC.lineColor = [UIColor blueColor];            //修改segment标题与内容的分割线颜色
    [self.navigationController pushViewController:segmentVC animated:YES];

Latest podspec

{
    "name": "CAPSegment",
    "version": "1.3.1",
    "summary": "A delightful iOS segment view controller framework.",
    "description": "It is a segment view controller framework on iOS, which implement by Objective-C.",
    "homepage": "https://github.com/captain9911/CAPSegment",
    "license": "MIT",
    "authors": {
        "captain9911": "[email protected]"
    },
    "source": {
        "git": "https://github.com/captain9911/CAPSegment.git",
        "tag": "1.3.1"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "CAPSegment/*.{h,m}"
}

Pin It on Pinterest

Share This