Skip to content

Commit ccde3b6

Browse files
committed
Merge branch 'master' of github.com:alexhillc/AXStateButton
2 parents 0ceadcb + 13625b4 commit ccde3b6

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AXStateButton
2+
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:
3+
4+
```objc
5+
AXStateButton *button = [AXStateButton button];
6+
7+
// some arbitrary customizations
8+
[button setCornerRadius:0.0f forState:UIControlStateNormal];
9+
[button setCornerRadius:6.0f forState:UIControlStateSelected];
10+
[button setCornerRadius:6.0f forState:UIControlStateHighlighted | UIControlStateSelected];
11+
12+
[button setTransformRotationZ:0 forState:UIControlStateNormal];
13+
[button setTransformRotationZ:M_PI_4 forState:UIControlStateSelected];
14+
15+
// customize the rest of your button...
16+
17+
[self.view addSubview:button];
18+
```
19+
20+
### "Well, what properties are state-configurable?"
21+
* Tint color
22+
* Background color
23+
* Alpha
24+
* Corner radius
25+
* Border color
26+
* Border width
27+
* Transform rotation (x, y, z)
28+
* Transform scale
29+
* Shadow color
30+
* Shadow opacity
31+
* Shadow offset
32+
* Shadow radius
33+
* Shadow path
34+
35+
#### Todo?
36+
* Custom view for state
37+
38+
### Other useful things
39+
You can also adjust the animation duration of your state transitions:
40+
```objc
41+
button.controlStateAnimationDuration = 0.1;
42+
```
43+
44+
Or, you can disable animations all together:
45+
```objc
46+
button.animateControlStateChanges = NO;
47+
```
48+
49+
For convenience, it's possible to access your set values:
50+
```objc
51+
CGFloat cornerRadius = [button cornerRadiusForState:UIControlStateHighlighted | UIControlStateSelected];
52+
// great success!
53+
```
54+
55+
### Contributions
56+
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!

0 commit comments

Comments
 (0)