LHToolbar 1.3.0-beta

LHToolbar 1.3.0-beta

测试已测试
语言 Obj-CObjective C
许可证 MIT
发布最新发布2016 年 7 月

LucasHuang 维护。



LHToolbar 1.3.0-beta

描述

LHToolbar 是在 iOS 应用程序中创建工具栏的替代方式。工具栏在 iOS 应用程序中广泛应用,然而,UIToolbar 类缺乏更新和灵活性,在一定程度上不可定制。这激发了我创建一个类似工具栏的容器,以便开发者在布局和 UI 上有更多的控制和灵活性。LHToolbar 专注于提供完全功能的工具栏容器、容器项操作以及在未来的更多功能。

功能

  • 基于 AutoLayout 的工具栏容器

即将推出的功能

  • 基于垂直 AutoLayout 的工具栏容器
  • 支持可滚动内容
  • 支持不同大小的内容视图项

使用示例

// initialize tool bar
LHToolbar *toolbar = [[LHToolbar alloc] initWithNumberOfItems:9];
toolbar.backgroundColor = [UIColor lightGrayColor];
CGRect mainScreenBounds = [UIScreen mainScreen].bounds;
CGFloat offset = 50.0f;
toolbar.frame = CGRectMake(offset / 2, CGRectGetHeight(mainScreenBounds) - toolbarHeight - colorToolbarHeight, CGRectGetWidth(mainScreenBounds) - offset, colorToolbarHeight);
[self.view addSubview:toolbar];

// add color picker buttons
NSDictionary *colorDict = @{
    @1: [UIColor colorWithRed:68.0/255.0f green:140.0/255.0f blue:230.0/255.0f alpha:1.0],
    @2: [UIColor colorWithRed:179.0/255.0f green:0/255.0f blue:223.0/255.0f alpha:1.0],
    @3: [UIColor redColor],
    @4: [UIColor colorWithRed:245.0/255.0f green:152.0/255.0f blue:0/255.0f alpha:1.0],
    @5: [UIColor colorWithRed:247.0/255.0f green:234.0/255.0f blue:0/255.0f alpha:1.0],
    @6: [UIColor colorWithRed:101.0/255.0f green:210.0/255.0f blue:0.0/255.0f alpha:1.0],
    @7: [UIColor blackColor],
    @8: [UIColor grayColor],
    @9: [UIColor whiteColor]
};
for (NSInteger i = 1; i < 10; i++) {
    UIButton *button = [[UIButton alloc] init];
    [button setBackgroundColor:colorDict[@(i)]];
    [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(gap, gap, (CGRectGetWidth(mainScreenBounds) - offset) / 9.0 - gap * 2, colorToolbarHeight - gap * 2)];
    [button.layer setCornerRadius:colorToolbarHeight / 2.0f];
    [toolbar setContentView:button atIndex:i -  1];
}

// reload tool bar
[toolbar reloadToolbar];

要求

  • iOS 8.0+
  • ARC

安装

LHToolbar 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile:

pod "LHToolbar"

作者

Lucas Huang, [email protected]

贡献

请遵循以下甜蜜的 贡献指南

许可证

LHToolbar 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。