XSegmentControl
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
XSegmentControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'XSegmentControl'
Usage
// 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 {
}
The delegate is optional.
Author
papfish, [email protected]
License
XSegmentControl is available under the MIT license. See the LICENSE file for more info.