Latest 1.0.1
Homepage https://github.com/dhumblet/DHOptionsMenu
License MIT
Platforms ios 7.0, requires ARC
Authors

An Android inspired options menu for iOS.

Screenshot


DHOptionsMenu

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

#import "DHOptionsMenu.h"

Implement DHOptionsMenuDelegate

@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.

Latest podspec

{
    "name": "DHOptionsMenu",
    "version": "1.0.1",
    "platforms": {
        "ios": "7.0"
    },
    "summary": "An Android inspired options menu for iOS.",
    "description": "A dropdown options menu that can be called from any UIView component.",
    "homepage": "https://github.com/dhumblet/DHOptionsMenu",
    "screenshots": "https://raw.githubusercontent.com/dhumblet/DHOptionsMenu/master/Screenshot.png",
    "license": "MIT",
    "authors": {
        "Derk Humblet": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dhumblet/DHOptionsMenu.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "DHOptionsMenu",
        "DHOptionsMenu/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This