Skip to content

Objective-C library that shows a menu tool to navigate through UIViewControllers

License

Notifications You must be signed in to change notification settings

enricmacias/EMLMenuBar

Repository files navigation

EMLMenuBar

CI Status Version License Platform

Description

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.

alt tag

Requirements

  • iOS 7.0
  • ARC

Usage

Check the example project in the "Example" folder.

Quick setup

  1. Create a UIView in Interface Builder with EMLMenuBar as a class. (The buttons will have the height of this view)

alt tag 2. Adopt EMLMenuBarDataSource and EMLMEnuBarDelegate into your UIViewController.

@interface EMLMainViewController : UIViewController <EMLMenuBarDelegate, EMLMenuBarDataSource>
  1. Assign the delegate and datasource to your UIViewController.

alt tag 4. Implement the EMLMenuBarDataSource and its required methods:

- (NSUInteger)itemCountInMenuBar:(EMLMenuBar *)menuBar;
- (NSString *)itemTitleAtIndex:(NSUInteger)index inMenuBar:(EMLMenuBar *)menuBar;
  1. Implement the EMLMEnuBarDelegate and its required method:
- (void)itemSelectedAtIndex:(NSUInteger)index inMenuBar:(EMLMenuBar *)menuBar;
  1. Init the menu bar in you 'viewDidLoad:':

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        [self.menuBar setup];
        self.menuBar.selectedItemIndex = 0;
    }

Customization

  • Choose one of the three types of button alineation:

    EMLMenuBarStyleNone (Default). The width is the one set in EMLMenuBarDataSource. alt tag

    EMLMenuBarStyleFitText alt tag

    EMLMenuBarStyleFillMenu alt tag

  • 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;

Installation

Cocoapods

EMLMenuBar is available through CocoaPods.

pod "EMLMenuBar"

Manually

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

Author

enric.macias.lopez, [email protected]

License

EMLMenuBar is available under the MIT license. See the LICENSE file for more info.

About

Objective-C library that shows a menu tool to navigate through UIViewControllers

Resources

License

Stars

Watchers

Forks

Packages

No packages published