Skip to content

JackySONE/SRPPopupMenu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LICENSE Donate Carthage compatible

SRPPopupMenu

中文說明

A dragable, easy customizable, popup menu.

Online Demo powered by appetize

Usage

You should use your own menu, not SRPPopupMenu.

Follow the steps to create your custom menu or reference the DemoMenu class.

Step1

Create your custom menu subclass SRPPopupMenu.

Override the method awakeFromNib and setting the animation properties.

Don't forget to call [super awakeFromNib].

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.otherButtonsAnimationDuration  = .5f;
    self.otherButtonsAnimationDamping   = .4f;
    self.otherButtonsPosionStartAngle   = -90.0f;
    self.othersButtonDistanceFromCenter = 120.0f;
    self.mainButtonAnimationDuration    = .5f;
    self.mainButtonAnimationDamping     = .6f;
}

Step2

Create a xib file named with your custom menu class name.

Disable the AutoLayout and Size-Class.

Drag a button to be MainButton, and connect to IBOutlet.

Drag some buttons to be otherButtons, and conncet to IBCollections.

Important: you must to set the button tag, start 1 to N.

Now you can use your custom menu.

// Show the menu
[[YourMenu singleton]show];

// Hide the menu
[[YourMenu singleton]hide];

Handle button clicked

The SRPPopupMenu using NSNotification to handle button clicked,

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter]addObserver:self
                                            selector:@selector(__menuButtonClickedNotification:)
                                                name:SRPPopupMenuButtonClickedNotification
                                              object:nil];
    
    
}

- (void)__menuButtonClickedNotification:(NSNotification *)sender
{
    NSNumber *tag = sender.object;
    NSLog(@"%@", tag);
}

Handle menu open / close

If you want to handle the menu open / close, you must implement the SRPPopupMenuProtocol methods.

Also see DemoMenu class.

// Menu will open
- (void)menuWillOpen

// Menu opened
- (void)menuDidOpen

// Menu will close
- (void)menuWillClose

// Menu closed
- (void)menuDidClose

About

A dragable, easy customizable, popup menu.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 100.0%