Skip to content

Commit 5729f46

Browse files
Merge commit '8e7a9dec930546d3729c6ae2a6ccdea9f576a0e8'
# Conflicts: # README.md
2 parents 01fd22d + 8e7a9de commit 5729f46

1 file changed

Lines changed: 120 additions & 0 deletions

File tree

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ButtonClickStyle
2+
3+
![image](https://github.com/mrustaa/GifPresentations/blob/master/ButtonClickStyle/preview_10sec33fps.gif)
4+
5+
This is a customizable designable button view.
6+
7+
Inside the layer you can style your button, create your own subviews.
8+
9+
Can choose 1 of 9 button click animation styles.
10+
11+
You can expand the project adding new click-animation-styles.
12+
13+
## Requirements
14+
15+
- macOS 10.12+
16+
- Xcode 13+
17+
- Swift 5.5+
18+
19+
## Installation
20+
21+
## Usage
22+
23+
#### С storyboard или xib
24+
25+
1) Create a "view" that inherits from `ButtonClickStyleView`
26+
27+
2) Inside this layer, create your own button
28+
29+
3) In Attributes Inspector of Interface Builder
30+
you can immediately select the button click `animationType`
31+
32+
33+
![image](https://github.com/mrustaa/GifPresentations/blob/master/ButtonClickStyle/click_styles_example_2x_10sec33fps.gif)
34+
35+
```swift
36+
extension ButtonClick {
37+
enum Style {
38+
case alpha
39+
case flash
40+
case shadow
41+
case shadowColor
42+
case color
43+
case colorFlat
44+
case pulsateNew
45+
case pulsate
46+
case press
47+
case shake
48+
case shakeNew
49+
case androidClickable
50+
case androidClickableDark
51+
}
52+
}
53+
```
54+
55+
4) Also you can select specific layers to animate / or just 1 specific one `allSubviews`
56+
57+
58+
5) Add animation duration `animationDuration`
59+
60+
6) Add animation value `animationTypeValue` - meaning means
61+
- "Hide .Alpha/Flash/Shadow/Color" - will change alpha from 0.0 to 1.0
62+
- "Move .Pulsate/Press/Shake" - will increase movement decrease from 0.0 to 1.0
63+
- "Add .AndroidClickable" - will increase bubble radius
64+
65+
66+
```swift
67+
@IBInspectable var allSubviews: Bool = true
68+
@IBInspectable var animationType: Int = 0
69+
@IBInspectable var animationValue: CGFloat = 0.0
70+
@IBInspectable var animationDuration: CGFloat = 0.0
71+
72+
var addViews: [UIView]?
73+
```
74+
75+
<!-- ![image](https://github.com/mrustaa/GifPresentations/blob/master/ButtonClickStyle/ui3.gif) -->
76+
77+
7) If initializing programmatically
78+
There is a property `addViews` - allows you to pass views / layers
79+
which you definitely want to use in the click animation only
80+
81+
8) Or initialize through a struct `ButtonClick.State`
82+
83+
```swift
84+
extension ButtonClick {
85+
struct State: Equatable {
86+
var titleText: String?
87+
var allSubviews: Bool = true
88+
var animationType: Int?
89+
var animationTypeValue: CGFloat?
90+
var animationDuration: CGFloat?
91+
var new: Bool = false
92+
var color: UIColor?
93+
var startClick: Bool = false
94+
var addBackgrondColor: Bool = true
95+
}
96+
}
97+
```
98+
99+
![image](https://github.com/mrustaa/GifPresentations/blob/master/ButtonClickStyle/ui3.gif)
100+
101+
```swift
102+
@IBOutlet var mainView: UIView!
103+
104+
var views: [UIView]? = [mainView]
105+
let frame: CGRect = .init(x: 23 , y: 22, width: 156, height: 48)
106+
let viewAn = ButtonClickStyleView(
107+
state: state,
108+
frame: frame,
109+
radius: 20,
110+
addViews: views
111+
)
112+
btnView.insertSubview(mainView, at: 0)
113+
btnView.updateSubviews()
114+
115+
```
116+
117+
## License
118+
119+
ButtonClickStyle is released under the MIT license.
120+

0 commit comments

Comments
 (0)