HXSegmentButton 0.1.1

HXSegmentButton 0.1.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最后发布2017年2月

Haixiao维护。



  • 作者:
  • Insofan

示例

要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install

要求

安装

HXSegmentButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "HXSegmentButton"

屏幕截图

CTuwV.gif

用法

1. 设置 SegmentButton
//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;
}
2. 初始化按钮标签
 [self.segmentButton initButtonTagWith:0];
3. 接收回调值
 //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];
    }];
4. 设置下划线动画
[self.segmentButton setupUnderLineAnimation];

作者

Insofan, [email protected]

许可证

HXSegmentButton 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。