XpdButtons 1.0.4

XpdButtons 1.0.4

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

Ravi Prakash 维护。




firstScreen firstScreen

XpdButtons 是一个库,可以动态生成一个视图,其中多个按钮根据按钮标题长度合理排列。一页视图中的行数必须固定,如果按钮更多,它将会显示在下一页视图中。

使用方法

XpdButtonContainer

XpdButtonContainer 创建了一个控制器,您可以在此设置按钮属性和外观。然后您可以获取一个包含按钮合理排列的 UIView

创建按钮视图

buttonproperties 是一个数组,包含按钮信息和标题的字典。在您的 .h 文件中 #import<XpdButtons/XpdButtonContainer.h>

XpdButtonContainer *buttonPageController = [[XpdButtonContainer alloc] init];
// self <--- in which viewContoller you gonna use the view.
buttonPageController.delegate = self;
buttonPageController.buttonProperties = buttonproperties; // NSArray
// Set your other properties for buttons.
buttonPageController.numberOfMaxRow = 3; // Default is 2
UIView *buttonView = [buttonPageController getXpdButtonsViewForParentViewController:self];

XpdButtonAction

XpdButtonAction 是检测按钮点击的 @protocol。实现以下方法以知道何时按钮被点击。 - (void) buttonGetClicked:(XpdButton *)button;

XpdButtonContainer @property

buttonProperties

buttonProperties 包含两个键的字典数组。

  1. title 正标题将来展示在按钮标题上。
  2. buttonInfo 是一个字典。

提示:在以下代理方法中,buttonInfo 对按钮点击将很有用。

- (void) buttonGetClicked:(XpdButton *)button;

例子
NSArray *properties = @[
                            @{
                                @"title" : @"button 1",
                                @"buttonInfo" : @{@"key" : @"value"}
                            },
                            @{
                                @"title" : @"button 2",
                                @"buttonInfo" : @{@"key" : @"value"}
                            }];
- (void) buttonGetClicked:(XpdButton *)button {
            if ([[button.buttonInfo objectForKey:@"somekey"] isEqualToString:@"somevalue"]) {
                // Do something
            }
            if ([button.title isEqualToString:@"Button 1"]) {
                // Do something
            }                                           
        }

numberOfMaxRow

numberOfMaxRow 一页视图中应有多少最大行数。 默认最大行数为 2

buttonBorderColor

buttonBorderColor 设置按钮边框颜色。 默认是黑色。

buttonTitleColor

buttonTitleColor 设置按钮标题颜色。 默认是黑色。

buttonHighlightedTitleColor

buttonHighlightedTitleColor 设置按钮标题在突出显示状态下的颜色。 默认为红色。

pageIndicatorTintColor

pageIndicatorTintColor 设置页面指示器着色颜色。 默认为浅灰色。

currentPageIndicatorTintColor

currentPageIndicatorTintColor 设置当前页面指示器着色颜色。 默认为黑色。

方法

-(UIView *) getXpdButtonsViewForParentViewController:(UIViewController *)parent;

返回一个视图,该视图包含在 buttonProperties 中设置的按钮

如何运行示例

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

安装

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

pod "XpdButtons"

贡献

你想要帮助使其更好、更容易使用。向我发送 pull request😃PS: 请在 development 分支上发送 pull request。

作者

Ravi Prakash, [email protected]

许可证

XpdButtons 适用于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。