Giter VIP home page Giter VIP logo

axstatebutton's Introduction

AXStateButton

AXStateButton is a simple UIButton subclass that offers state-based button customization akin to that of Apple's. The idea is nothing fancy, but can be used as the building blocks to create something a bit more complex. All it takes to get started is:

AXStateButton *button = [AXStateButton button];

// some arbitrary customizations
[button setCornerRadius:0.0f forState:UIControlStateNormal];
[button setCornerRadius:6.0f forState:UIControlStateSelected];
[button setCornerRadius:6.0f forState:UIControlStateHighlighted | UIControlStateSelected];

[button setTransformRotationZ:0 forState:UIControlStateNormal];
[button setTransformRotationZ:M_PI_4 forState:UIControlStateSelected];

// customize the rest of your button...

[self.view addSubview:button];

"Well, what properties are state-configurable?"

  • Tint color
  • Background color
  • Alpha
  • Title alpha
  • Image alpha
  • Corner radius
  • Border color
  • Border width
  • Transform rotation (x, y, z)
  • Transform scale
  • Shadow color
  • Shadow opacity
  • Shadow offset
  • Shadow radius
  • Shadow path

Todo?

  • Custom view for state

Other useful things

You can also adjust the animation duration of your state transitions:

button.controlStateAnimationDuration = 0.1;

On top of that, you can change the timing function used when animating control state changes:

button.controlStateAnimationTimingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

Or, you can disable animations all together:

button.animateControlStateChanges = NO;

For convenience, it's possible to access your set values:

CGFloat cornerRadius = [button cornerRadiusForState:UIControlStateHighlighted | UIControlStateSelected];
// great success!

Contributions

If you see a bug, you are welcome to open a Github issue and I will attempt to get to it as soon as I can. Of course, you are also welcome to fork the repo and create a pull request with your changes. I'd be happy to look them over!

axstatebutton's People

Contributors

alexhillc avatar carlosmejiagrove avatar

Watchers

 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.