RobotsAndPencils / RPSlidingMenu

A collection view menu in the style of UltraVisual.
MIT License
861 stars 109 forks source link

RPSlidingMenu

A collection view menu in the style of UltraVisual.

RPSlidingMenu animated GIF

Youtube Video

Installation

From CocoaPods

Add pod 'RPSlidingMenu' to your Podfile

Usage

(see sample Xcode project in /Demo)

Create a new file that inherits from RPSlidingMenuViewController

Override the following methods:

// return the number of menu items
- (NSInteger)numberOfItemsInSlidingMenu;
// set properties of the cell like the textLabel.text, detailLabel.text and backgroundImageView.image
- (void)customizeCell:(RPSlidingMenuCell *)slidingMenuCell forRow:(NSInteger)row;
// optionally to handle a menu item being tapped
- (void)slidingMenu:(RPSlidingMenuViewController *)slidingMenu didSelectItemAtRow:(NSInteger)row;

Example of code in .m

- (NSInteger)numberOfItemsInSlidingMenu {
    return 10; // 10 menu items
}

- (void)customizeCell:(RPSlidingMenuCell *)slidingMenuCell forRow:(NSInteger)row {
    slidingMenuCell.textLabel.text = @"Some Title";
    slidingMenuCell.detailTextLabel.text = @"Some longer description that is like a subtitle!";
    slidingMenuCell.backgroundImageView.image = [UIImage imageNamed:@"some_image"];

}

- (void)slidingMenu:(RPSlidingMenuViewController *)slidingMenu didSelectItemAtRow:(NSInteger)row {
    // when a row is tapped do some action like go to another view controller
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Row Tapped"
                                                    message:[NSString stringWithFormat:@"Row %d tapped.", row]
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
}

Notes

Contact

Robots & Pencils Logo

Follow Robots & Pencils on Twitter (@robotsNpencils)

Maintainers

License

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