Latest 1.0.0
Homepage https://github.com/MDSilber/MSButtonPanel
License MIT
Platforms ios 6.0, requires ARC
Authors

MSButtonPanel is a UIView subclass that holds a row of buttons. Each button expands or collapses dynamically on selection.
Here’s a short GIF showing it in action:

Test

All developers need to do to initialize it is to pass in an array of strings to be displayed when each respective button is selected (as well as optional parameters for background colors, text colors, and fonts).

Then, to set actions on each button, developers have two options. The first is to set the button panel’s delegate and implement the delegate method - (void)buttonPanelDidSelectButtonWithIndex:(NSInteger)index, and the other is to pass a target and selectors through in the alternative instance method - (instancetype)initWithButtonTitles:(NSArray *)buttonTitles target:(id)target andSelectors:(NSArray *)selectors. Example of each technique is displayed below.

Delegate method:

MSButtonPanel *buttonPanel = [[MSButtonPanel alloc] initWithButtonTitles:@[@"Test", @"Test", @"Test", @"Test", @"Test"]];
buttonPanel.delegate = self;
[self.view addSubview:buttonPanel];

Then implement the delegate method to handle selection based on the selected index.

Target/selector method:

MSButtonPanel *buttonPanel = [[MSButtonPanel alloc] initWithButtonTitles:@[@"Test", @"Test", @"Test", @"Test", @"Test"] target:self andSelectors:@[[NSValue valueWithPointer:@selector(selector1)], [NSValue valueWithPointer:@selector(selector2)], [NSValue valueWithPointer:@selector(selector3)], [NSValue valueWithPointer:@selector(selector4)], [NSValue valueWithPointer:@selector(selector5)]]];
[self.view addSubview:buttonPanel];

Note that selectors passed through an array must be passed as NSValues.

An example of each of these can be found in the example project attached. If you have any questions, feel free to email me at [email protected] Good luck!

TODO: Support multiple orientations (with autolayout?)

Latest podspec

{
    "name": "MSButtonPanel",
    "version": "1.0.0",
    "summary": "A panel of UIButtons that dynamically expand and collapse when selected",
    "homepage": "https://github.com/MDSilber/MSButtonPanel",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mason Silber": "[email protected]"
    },
    "source": {
        "git": "https://github.com/MDSilber/MSButtonPanel.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source_files": [
        "Classes",
        "Classes/**/*.{h,m}"
    ],
    "public_header_files": "Classes/**/*.h",
    "requires_arc": true
}

Pin It on Pinterest

Share This