TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2017 |
Maintained by Haixiao.
To run the example project, clone the repo, and run pod install
from the Example directory first.
HXSegmentButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HXSegmentButton"
//1.Setup SegmentButton
- (HXSegmentButton *)segmentButton {
if (!_segmentButton) {
NSArray *array = @[@"Button0", @"Button1", @"Button2", @"Button3"];
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
//1.1 Setup segment button frame
_segmentButton = [[HXSegmentButton alloc] initWithTitles:array x:0 y:64 width:screenWidth height:36];
//1.2 Setup segment button colors
[_segmentButton setupButtonsNormalColor:[UIColor whiteColor] selectedColor:[UIColor redColor]];
//1.3 Setup segment button background colors and underLine color
[_segmentButton setupBackgroundNormalColor:[UIColor blackColor] selectedColor:[UIColor yellowColor] underLineColor:[UIColor redColor]];
[self.view addSubview:_segmentButton];
}
return _segmentButton;
}
[self.segmentButton initButtonTagWith:0];
//3.1Callback block
__weak typeof(self) weakSelf = self;
[_segmentButton returnHeaderIndex:^(NSUInteger current) {
__strong typeof(weakSelf) strongSelf = weakSelf;
NSLog(@"%ld", current);
//3.2 Receive the button tag
[strongSelf segmentButtonTag:current];
}];
[self.segmentButton setupUnderLineAnimation];
Insofan, [email protected]
HXSegmentButton is available under the MIT license. See the LICENSE file for more info.