@@ -44,7 +44,6 @@ pod 'ButtonClickStyle'
44443 ) In Attributes Inspector of Interface Builder
4545 you can immediately select the button click style ` animationType `
4646
47-
4847![ image] ( https://github.com/mrustaa/GifPresentations/blob/master/ButtonClickStyle/click_styles_example_2x_10sec33fps.gif )
4948
5049``` swift
@@ -74,58 +73,73 @@ extension ButtonClick {
74735 ) Add animation duration ` animationDuration `
7574
76756 ) Add animation value ` animationTypeValue ` - meaning means
77- - "Hide .Alpha/Flash/Shadow/Color" - will change alpha from 0.0 to 1.0
78- - "Move .Pulsate/Press/Shake" - will increase movement decrease from 0.0 to 1.0
79- - "Add .AndroidClickable" - will increase bubble radius
80-
81-
82- ``` swift
83- @IBInspectable var allSubviews: Bool = true
84- @IBInspectable var animationType: Int = 0
85- @IBInspectable var animationValue: CGFloat = 0.0
86- @IBInspectable var animationDuration: CGFloat = 0.0
87-
88- var addViews: [UIView]?
89- ```
76+ - "Hide .Alpha/.Flash" - will change alpha from 0.0 to 1.0
77+ - "Add .Shadow/.Color/.ColorFlat"
78+ - "Move .Pulsate/.Press/.Shake" - will increase movement decrease from 0.0 to 1.0
79+ - "TapGesture .Fave/.AndroidClickable" - will increase bubble radius
80+ - "Loading .Glare" -
9081
9182<!--  -->
9283
93847 ) If initializing programmatically
9485There is a property ` addViews ` - allows you to pass views / layers
9586which you definitely want to use in the click animation only
9687
97- ``` swift
98- @IBOutlet var mainView: UIView!
99-
100- var views: [UIView]? = [mainView]
101- let frame: CGRect = .init (x : 23 , y : 22 , width : 156 , height : 48 )
102- let viewAn = ButtonClickStyleView (
103- state : state,
104- frame : frame,
105- radius : 20 ,
106- addViews : views
107- )
108- btnView.insertSubview (mainView, at : 0 )
109- btnView.updateSubviews ()
110-
111- ```
112-
113-
114888 ) Or initialize through a struct ` ButtonClick.State `
11589
11690``` swift
117- extension ButtonClick {
118- struct State : Equatable {
119- var titleText: String ?
120- var allSubviews: Bool = true
121- var animationType: Int ?
122- var animationTypeValue: CGFloat?
123- var animationDuration: CGFloat?
124- var new: Bool = false
125- var color: UIColor?
126- var startClick: Bool = false
127- var debugButtonShow: Bool = false
128- var addBackgrondColor: Bool = true
91+ import ButtonClickStyle
92+ import UIKit
93+
94+ class ViewController : UIViewController {
95+
96+ @IBOutlet var xibButtonClickStyleView: ButtonClickStyleView?
97+
98+ var prgmButtonClickStyleView: ButtonClickStyleView?
99+ var prgmFigureView: UIView!
100+ var prgmRectangleView: UIView!
101+
102+ // MARK: - Create Programmaticaly
103+
104+ override func viewDidLoad () {
105+ super .viewDidLoad ()
106+
107+ let figureView = UIView (frame : .init (x : 50 , y : 10 , width : 80 , height : 40 ))
108+ figureView.backgroundColor = .systemIndigo
109+ figureView.layer .cornerRadius = 20
110+ self .prgmFigureView = figureView
111+
112+ let rectangleView = UIView (frame : .init (x : 15 , y : 50 , width : 50 , height : 60 ))
113+ rectangleView.backgroundColor = .systemPurple
114+ self .prgmRectangleView = rectangleView
115+
116+ let state = ButtonClick.State (
117+ titleText : " Hello" , // debug text button
118+ allSubviews : true , // click animation all subviews
119+ animationType : 2 , // style 15
120+ animationTypeValue : 0.5 , // value - alpha/power move
121+ animationDuration : nil , // anim duration
122+ new : false , // same styles one of them new
123+ color : UIColor.green , // value color for styles shadowColor/color/colorFlat
124+ startClick : true , // animate on creation
125+ debugButtonShow : false , // debug highlight the real button inside
126+ addBackgrondColor : true // debug add background color/view
127+ )
128+
129+ let btnView = ButtonClickStyleView (
130+ state : state,
131+ frame : .init (x : 0 , y : 300 , width : 240 , height : 128 ),
132+ radius : 20 ,
133+ addViews : [figureView] // addViews - allows you to pass views / layers which you definitely want to use in the click animation only
134+ )
135+ btnView.backgroundColor = .yellow .withAlphaComponent (0.5 )
136+
137+ btnView.updateSubviews ()
138+ self .prgmButtonClickStyleView = btnView
139+
140+ btnView.addSubview (figureView)
141+ btnView.addSubview (rectangleView)
142+ self .view .addSubview (btnView)
129143 }
130144}
131145```
0 commit comments