GithubHelp home page GithubHelp logo

dgexpandmenubutton's Introduction

Description

The ExpandMenuButton inspired by the prototype in dribbble(here is the link). Thanks to the prototype author - Pablo Stanley.

Screenshot

img

Usage

Initialize e.g

UIButton *btn1 = [UIButton buttonWithType: UIButtonTypeCustom];
[btn1 setImage: [UIImage imageNamed: @"cart"] forState: UIControlStateNormal];

UIButton *btn2 = [UIButton buttonWithType: UIButtonTypeCustom];
[btn2 setImage: [UIImage imageNamed: @"setting"] forState: UIControlStateNormal];

UIButton *btn3 = [UIButton buttonWithType: UIButtonTypeCustom];
[btn3 setImage: [UIImage imageNamed: @"user"] forState: UIControlStateNormal];

DGExpandMenuButton *ExpandMenuButton = [[DGExpandMenuButton alloc] initWithFrame: CGRectMake(self.view.frame.size.width / 2 - 40, 360, 80, 80) superView: self.view  andObjects: btn1, btn2, btn3, nil];

[self.view addSubview: ExpandMenuButton];

Implement

- (void)addOneButton:(UIButton *)btn;

The method can let you to add a new button freedomly and smoothly. It will check the menu status to judge whether the new button needs a animation.

e.g
- (void)viewDidLoad {
    // ...
    UIButton *plus = [UIButton buttonWithType: UIButtonTypeCustom];
    [plus setImage:[UIImage imageNamed:@"plus"] forState:UIControlStateNormal];
    plus.frame = CGRectMake(185, 200, 40, 40);
    [plus addTarget:self action:@selector(addButton) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview: plus];
}

- (void)addButton {
    UIButton *btn5 = [UIButton buttonWithType: UIButtonTypeCustom];
    btn5.backgroundColor = [UIColor grayColor];
    [_ExpandMenuButton addOneButton:btn5];
}
[_ExpandMenuButton addOneButton:btn]; img

- (void)delLastButton;

The method can let you to delete the last button in the menu, smoothly and quickly. And this interface is a internal method with gesture - Swip Down.

e.g
[_expandMenuButton delLastButton]; img

- (void)rotateAllButton;

When the menu buttons has been to the max number, you can trigger this function to rotate all buttons.

e.g
[_expandMenuButton rotateAllButton]; img

- (void)showButtonIndex;

This function can show the index of every buttons. You will use it when using function behind, if you like.

- (void)turnedFrom:(int)indA to:(int)indB

You can exchange position the buttons' position by this function. And you need to know the index of the button by showButtonIndex function.

e.g
[_ExpandMenuButton turnedFrom:val1 to:val2]; img

Next Feature

If you want to add some special feature, you can start a pull request or a issue to tell me the good idea!

The MIT License (MIT)

Copyright (c) 2016 Desgard_Duan.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

dgexpandmenubutton's People

Contributors

desgard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dgexpandmenubutton's Issues

有的button不能添加点击事件?

UIButton *btn1 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn1 setImage: [UIImage imageNamed: @"cart"] forState: UIControlStateNormal];
	[btn1 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

    UIButton *btn2 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn2 setImage: [UIImage imageNamed: @"setting"] forState: UIControlStateNormal];
	[btn2 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

    UIButton *btn3 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn3 setImage: [UIImage imageNamed: @"user"] forState: UIControlStateNormal];
	[btn3 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

demo里面的代码添加,只有btn1会响应事件

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.