Implements a scrollable view with buttons in it. Offers different delegate methods to use it as a menu bar and some design and animation customization.
- iOS 7.0
- ARC
Check the example project in the "Example" folder.
- Create a UIView in Interface Builder with EMLMenuBar as a class. (The buttons will have the height of this view)
2. Adopt EMLMenuBarDataSource and EMLMEnuBarDelegate into your UIViewController.
@interface EMLMainViewController : UIViewController <EMLMenuBarDelegate, EMLMenuBarDataSource>
- Assign the delegate and datasource to your UIViewController.
4. Implement the EMLMenuBarDataSource and its required methods:
- (NSUInteger)itemCountInMenuBar:(EMLMenuBar *)menuBar;
- (NSString *)itemTitleAtIndex:(NSUInteger)index inMenuBar:(EMLMenuBar *)menuBar;
- Implement the EMLMEnuBarDelegate and its required method:
- (void)itemSelectedAtIndex:(NSUInteger)index inMenuBar:(EMLMenuBar *)menuBar;
-
Init the menu bar in you 'viewDidLoad:':
- (void)viewDidLoad { [super viewDidLoad]; [self.menuBar setup]; self.menuBar.selectedItemIndex = 0; }
-
Choose one of the three types of button alineation:
EMLMenuBarStyleNone (Default). The width is the one set in EMLMenuBarDataSource.
-
Modify the button design through interface builder with EMLMenuBarButton xib file:
EMLMenuBarButton.xib
- Create your own animation with:
- (void)appearanceForNormalStateMenuBarButton:(EMLMenuBarButton *)barButton;
- (void)appearanceForSelectedStateMenuBarButton:(EMLMenuBarButton *)barButton;
EMLMenuBar is available through CocoaPods.
pod "EMLMenuBar"
Import the following files into your project:
EMLMenuBar/Pod/Classes folder:
EMLMenuBar.h
EMLMenuBar.m
EMLMenuBarButton.h
EMLMenuBarButton.m
EMLMenuBarDataSource.h
EMLMenuBarDelegate.h
EMLMenuBar/Pod/Resources folder:
EMLMenuBarButton.xib
enric.macias.lopez, [email protected]
EMLMenuBar is available under the MIT license. See the LICENSE file for more info.