Latest 0.0.1
Homepage https://github.com/zhuyunfeng1224/XHSegmentController
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, UIKit
Authors

这是一款分段选择控制器,分XHSegmentViewControllerXHSegmentControl两部分
XHSegmentViewController通过添加子Controller实现,可以通过左右滑动页面来滑动选择器,适合用自定义segment来管理不同的页面
当然为了做到控件尽量轻量级,你也可以作为一个控件,单独使用XHSegmentControl

XHSegmentViewController

XHSegmentViewController使用如下,自定义ViewController并继承XHSegmentViewController,设置viewControllers属性
要点:要设置子ViewController的title,否则字体显示不出

     ViewController *vc1 = [[ViewController alloc] init];
     vc1.title = @"男装";
     ViewController *vc2 = [[ViewController alloc] init];
     vc2.title = @"女装";
     ViewController *vc3 = [[ViewController alloc] init];
     vc3.title = @"童装";
     self.viewControllers = @[vc1, vc2, vc3];

XHSegmentControl

XHSegmentControl是一个UIView类型的控件,可以设置控件背景色,添加底部高亮线,并设置标题字体和颜色等
有两种模式可通过segmentType属性来设置
分别是:

typedef NS_ENUM(NSInteger, XHSegmentType)
{
    XHSegmentTypeFilled = 0,    //  充满屏幕高度
    XHSegmentTypeFit,           //  适应文字大小
    XHSegmentTypeCircle         //  循环(待做)
};

@protocol XHSegmentControlDelegate <NSObject>
- (void)xhSegmentSelectAtIndex:(NSInteger)index animation:(BOOL)animation;
@end

XHSegmentControlDelegatesegmentControl的代理,包含方法可用来接受segment选择事件

Latest podspec

{
    "name": "XHSegmentController",
    "version": "0.0.1",
    "summary": "A segment controller used on iOS.",
    "description": "It is a segment controller, which implement by Objective-C.",
    "homepage": "https://github.com/zhuyunfeng1224/XHSegmentController",
    "license": "MIT",
    "authors": {
        "u7fb2u548c": "[email protected]om"
    },
    "source": {
        "git": "https://github.com/zhuyunfeng1224/XHSegmentController.git",
        "tag": "0.0.1"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "XHSegmentController/*",
    "frameworks": [
        "Foundation",
        "UIKit"
    ]
}

Pin It on Pinterest

Share This