Giter VIP home page Giter VIP logo

srppopupmenu's Introduction

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

srppopupmenu's People

Contributors

shinrenpan avatar turbobrian avatar

Watchers

Yan Yu, Lai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.