Need help with CMDAwesomeButton?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

calebd
123 Stars 5 Forks MIT License 37 Commits 0 Opened issues

Description

A UIButton subclass that is awesome.

Services available

!
?

Need anything else?

Contributors list

# 15,642
Objecti...
carthag...
deep-li...
deeplin...
29 commits
# 37,364
compile...
applesc...
macbook
swift3
1 commit
# 537,221
HTML
salesfo...
web-com...
Objecti...
1 commit
# 93,696
Swift
Objecti...
Shell
reactiv...
1 commit

CMDAwesomeButton

This is my button subclass. It is awesome.

It is powered by one method:

- (void)setValue:(id)value forKeyPath:(NSString *)keyPath state:(UIControlState)state;

This lets you set any value for any keypath for the given control state.

It also has convenience setters for a few common tasks:

- (void)setBackgroundColor:(UIColor *)color forState:(UIControlState)state;
- (void)setBorderColor:(UIColor *)color forState:(UIControlState)state;
- (void)setBorderWidth:(CGFloat)width forState:(UIControlState)state;
- (void)setCornerRadius:(CGFloat)radius forState:(UIControlState)state;

Awesome right?

There's also a handy

backgroundView
property. You can put whatever you want there. Let's say you have a gradient view. Do something like this:
CMDAwesomeButton *gradientButton = [CMDAwesomeButton new];

SAMgradientView *gradientView = [SAMGradientView new]; gradientView.backgroundColor = [UIColor clearColor]; gradientButton.backgroundView = gradientView;

[gradientButton setValue:@[ [UIColor colorWithRed:0.145 green:0.769 blue:0.757 alpha:1.000], [UIColor colorWithRed:0.196 green:0.678 blue:0.800 alpha:1.000] ] forKeyPath:@"backgroundView.gradientColors" state:UIControlStateNormal]; [gradientButton setValue:@[ [UIColor colorWithRed:0.145 green:0.769 blue:0.757 alpha:0.5], [UIColor colorWithRed:0.196 green:0.678 blue:0.800 alpha:0.5] ] forKeyPath:@"backgroundView.gradientColors" state:UIControlStateHighlighted];

Boom. (SAMGradientView is great. I use it in all my apps.)

If you would like more convenience setters feel free to send me a pull request!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.