Skip to content

dhumblet/DHOptionsMenu

Repository files navigation

DHOptionsMenu

An Android inspired options menu for iOS.

Screenshot

Installation

Using CocoaPods:

pod 'DHOptionsMenu', '~> 1.0'

Manual installation

Simple copy the files to a folder named "DHOptionsMenu" in your project.

How to use

#import "DHOptionsMenu.h"
@interface ViewController : UIViewController<DHOptionsMenuDelegate>
#pragma mark - DHOptionsMenuDelegate 

- (void)selectedMenuItem:(DHOptionsMenuItem *)item { }

- (void)menuDidHide { }

Create menu items

[[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]];

Create menu

[[DHOptionsMenu alloc] initWithItems:menuItems
	                  andItemSpacing:1
                    andItemAlignment:DHOptionsMenuAlignLeft
                 andCallingComponent:button // The UIView that triggered showing the menu
                        withDelegate:self];

Show menu

[menu showInView:self.view];

Hide menu

[menu hide];

Demo project

Please use the Demo project to play with the code yourself.

Alignment

  • 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

Further customization

DHOptionsMenuItem are an extension of UILabel and can be customized in a similar way.

  • Multiple lines.
  • Text alignment.
  • Truncation.
  • ...

Feedback

Please feel free to send me any feedback or ideas you might have.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published