TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2016 |
Maintained by Ravi Prakash.
XpdButtons is a library which generate a view with multiple buttons dynamically arrange according to button title length. Number of row in one page view have to be fix and if there is more buttons, it will show up in next page view.
XpdButtonContainer
creates a controller where you can set your button properties and the way button looks. Then you can get a UIView
in which buttons are properly arranged.
buttonproperties is an Array which holds dictionary of buttonInfo and title.
#import<XpdButtons/XpdButtonContainer.h>
In your .h
file.
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
@protocol for detecting buttons tap.
Implement following method to know when buttons got clicked.
- (void) buttonGetClicked:(XpdButton *)button;
buttonProperties
if an Array of Dictionary with two keys.
title
:- title is which gonna be shown on button title.buttonInfo
:- buttonInfo is Dictionary.Tips :- In following delegate method buttonInfo will be useful to take action on button tap.
- (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
How many maximum row should be in one page view. Default number of maximum row is 2
buttonBorderColor
Set button border color. Default is black.
buttonTitleColor
Set Button title color. Default is black.
buttonHighlightedTitleColor
Set Button title color in Highlighted condition. Default is red.
pageIndicatorTintColor
Set Page Indicator Tint color. Default is lightGray.
currentPageIndicatorTintColor
Set Current Page indicator tint color. Default is black.
-(UIView *) getXpdButtonsViewForParentViewController:(UIViewController *)parent;
Returns a view which holds all buttons which was set in buttonProperties
To run the example project, clone the repo, and run pod install
from the Example directory first.
XpdButtons is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "XpdButtons"
You wanna help to make it better and easy to use. Send me pull request development
branch.
Ravi Prakash, [email protected]
XpdButtons is available under the MIT license. See the LICENSE file for more info.