XSegmentControl
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
安装
XSegmentControl 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'XSegmentControl'
用法
// 1. create
_segControl = [[XSegmentControl alloc] initWithFrame:CGRectMake(0, 100, 375, 44)];
_segControl.delegate = self;
_segControl.separatorColor = [UIColor clearColor];
_segControl.selectedColor = [UIColor orangeColor];
_segControl.unselectedColor = [UIColor grayColor];
_segControl.titleFont = [UIFont boldSystemFontOfSize:20];
[_segControl setItemTitles:@[@"hello", @"world"]];
[self.view addSubview:_segControl];
......
// 2. delegate
#pragma mark - XSegmentControlDelegate
// The item will be selected.
- (BOOL)segmentControl:(XSegmentControl *)segmentControl willSelectItemAtIndex:(NSInteger)index {
return YES;
}
// The item did selected.
- (void)segmentControl:(XSegmentControl *)segmentControl didSelectItemAtIndex:(NSInteger)index {
}
代理人(delegate)是可选的。
作者
papfish,[email protected]
许可证
XSegmentControl可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。