An Android inspired options menu for iOS.
pod 'DHOptionsMenu', '~> 1.0'
Simple copy the files to a folder named "DHOptionsMenu" in your project.
Import DHOptionsMenu
#import "DHOptionsMenu.h"
Implement DHOptionsMenuDelegate
@interface ViewController : UIViewController<DHOptionsMenuDelegate>
#pragma mark - DHOptionsMenuDelegate
- (void)selectedMenuItem:(DHOptionsMenuItem *)item { }
- (void)menuDidHide { }
[[DHOptionsMenuItem alloc] initWithText:@"Text"
andItemSize:CGSizeMake(200, 40)
andFont:[UIFont fontWithName:@"System" size:10]
andTextColor:[UIColor blackColor]
andHighlightedTextColor:[UIColor blackColor]
andBackgroundColor:[UIColor whiteColor]
andHighlightedBackgroundColor:[UIColor whiteColor]];
[[DHOptionsMenu alloc] initWithItems:menuItems
andItemSpacing:1
andItemAlignment:DHOptionsMenuAlignLeft
andCallingComponent:button // The UIView that triggered showing the menu
withDelegate:self];
[menu showInView:self.view];
[menu hide];
Please use the Demo project to play with the code yourself.
- DHOptionsMenuAlignLeft: Aligns menu items with the left side of the view that triggered the menu
- DHOptionsMenuAlignRight: Aligns menu items with the right side of the view that triggered the menu
- DHOptionsMenuAlignCenter: Aligns menu items with the center of the view that triggered the menu
DHOptionsMenuItem are an extension of UILabel and can be customized in a similar way.
- Multiple lines.
- Text alignment.
- Truncation.
- ...
Please feel free to send me any feedback or ideas you might have.