MFExpandableMenu is an expandable menu for iOS 7 with transitions and styling.
- Automatically lighten menu items given base color
- Simple delegation leveraging UICollectionView under the hood
- Customizable fonts and colors
- Render any UIView as the menu item "detail view"
MFExpandableMenu is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "MFExpandableMenu", "~> 0.0.1"
You can find the sample project in Example/Demo
Displaying menu containing 4 items
MFExpandableMenuDataSource
- Used to determine amount and content of items in the menuMFExpandableMenuDelegate
- Provides callbacks when menu items are selected
#import <MFExpandableMenu/MFExpandableMenuViewController.h>
@interface ViewController : UIViewController <MFExpandableMenuDataSource, MFExpandableMenuDelegate>
In the implementation:
MFExpandableMenuViewController *menuViewController = [[MFExpandableMenuViewController alloc] init];
// Custom background fade color
menuViewController.customBackgroundFadeColor = [UIColor purpleColor];
// Assign dataSource and delegate properties
menuViewController.dataSource = self;
menuViewController.delegate = self;
// Show the menu
[self presentViewController:menuViewController animated:YES completion:nil];
Required dataSource
methods:
- (NSInteger)numberOfItemsInMenuViewController:(MFExpandableMenuViewController *)menuViewController {
return 4;
}
- (NSString *)menuViewController:(MFExpandableMenuViewController *)menuViewController
titleForMenuItemAtIndex:(NSInteger)index1 {
return [NSString stringWithFormat:@"Menu Item %d", index1 + 1];
}
- (UIView *)menuViewController:(MFExpandableMenuViewController *)menuViewController
detailViewForMenuItemAtIndex:(NSInteger)index1 {
return someUIView;
}
Optional delegate
methods:
- (void) menuViewController:(MFExpandableMenuViewController *)menuViewController
willShowDetailViewForMenuItemAtIndex:(NSInteger)index {
NSLog(@"Showing detail view for menu item at index: %i", index);
}
- (void) menuViewController:(MFExpandableMenuViewController *)menuViewController
willHideDetailViewForMenuItemAtIndex:(NSInteger)index {
NSLog(@"Hiding detail view for menu item at index: %i", index);
}
The following MFExpandableMenuViewController
properties can be customized:
UIFont *customMenuItemFont
- The font to use for the menu item labelsUIColor *customMenuItemTextColor
- The color to use for the menu item labelsUIColor *customBackgroundFadeColor
- The color to use for the initial menu item background color that will automatically lighten across subsequent items
To run the unit test suite:
$ cd Example
$ make install
$ make ci
Mark Fayngersh, [email protected]
MFExpandableMenu is available under the MIT license. See the LICENSE file for more info.