GithubHelp home page GithubHelp logo

miguelramosfdz / vbfpopflatbutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from victorbaro/vbfpopflatbutton

0.0 2.0 0.0 1.23 MB

Flat button with 9 different states using POP

License: MIT License

Ruby 2.19% Objective-C 97.81%

vbfpopflatbutton's Introduction

VBFPopFlatButton

Flat button with 21 different states and 2 types animated using pop.

These are some examples of both types in different states:

Examples

And here you can see them animated:

ButtonDribbble

##How to use it Best way is using Cocoapods

pod 'VBFPopFlatButton'

You can also clone and open example project. The class you have to use is VBFPopFlatButton (subclass of UIButton). You will also find VBFDoubleSegment which is just a helping class.

Here there is some example code on how to use the button:

Flat Rounded Style

//Example
self.flatRoundedButton = [[VBFPopFlatButton alloc]initWithFrame:CGRectMake(100, 150, 30, 30)
                                              buttonType:buttonMenuType
                                             buttonStyle:buttonRoundedStyle
                                             animateToInitialState:YES];
self.flatRoundedButton.roundBackgroundColor = [UIColor whiteColor];
self.flatRoundedButton.lineThickness = 2;
self.flatRoundedButton.tintColor = [UIColor flatPeterRiverColor];
[self.flatRoundedButton addTarget:self
                           action:@selector(flatRoundedButtonPressed)
                 forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.flatRoundedButton];

Flat Plain Style

//Example
self.flatPlainButton = [[VBFPopFlatButton alloc]initWithFrame:CGRectMake(200, 150, 30, 30)
                                                   buttonType:buttonAddType
                                                  buttonStyle:buttonPlainStyle
                                                  animateToInitialState:NO];
self.flatPlainButton.lineThickness = 2;
self.flatPlainButton.tintColor = [UIColor whiteColor];
[self.flatPlainButton addTarget:self
                         action:@selector(flatPlainButtonPressed)
               forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.flatPlainButton];

Requested feature added on 0.0.5 The designated initializer has changed to:

    - (instancetype)initWithFrame:(CGRect)frame 
                    buttonType:(FlatButtonType)initType 
                   buttonStyle:(FlatButtonStyle)bStyle 
        animateToInitialState:(BOOL)animateToInitialState;  

Adding the last 'animateToInitialState' boolean. Sending YES, the button will perform as in older versions (will animate on viewWillAppear from original type, represented as vertical line, to your initial type). Sending NO, the button will be presented using initial type with no animation on presentation.

In both cases, you can use the following method to animate the button from one state to the next:

[flatRoundedButton animateToType:nextType];

This are the 20 types avaiable for the button:

typedef NS_ENUM(NSInteger, FlatButtonType) {
buttonDefaultType,             // Vertical line
buttonAddType,                 // +
buttonMinusType,               // -
buttonCloseType,               // x
buttonBackType,                // <
buttonForwardType,             // >
buttonMenuType,                 // 3horizontal lines
buttonDownloadType,
buttonShareType,
buttonDownBasicType,
buttonUpBasicType,
buttonDownArrowType,
buttonPausedType,
buttonRightTriangleType,
buttonLeftTriangleType,
buttonUpTriangleType,
buttonDownTriangleType,
buttonOKType,
buttonRewindType,
buttonFastForwardType,
buttonSquareType
};

More types are welcomed :D

For more info, visit my blog victorbaro.com

Apps using this control

I would love to know which apps in the App Store are using this control. Please, feel free to add your app :)

vbfpopflatbutton's People

Contributors

ahnseonghyun avatar anlcan avatar brandonroeder avatar jibeex avatar jonasgessner avatar lonelytango avatar stoprocent avatar victorbaro avatar vincentsit avatar wolffan avatar

Watchers

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