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