@@ -13,12 +13,9 @@ import UIKit
1313class ButtonClickStyleView : UIView {
1414
1515 @IBInspectable var animationType : Int = 0
16-
17- @IBInspectable var allSubviews : Bool = true
1816 @IBInspectable var animationValue : CGFloat = 0.0
1917 @IBInspectable var animationDuration : CGFloat = 0.0
20- @IBInspectable var buttonColor : Bool = false
21- @IBInspectable var startClick : Bool = false
18+ @IBInspectable var allSubviews : Bool = true
2219
2320 var addViews : [ UIView ] ?
2421
@@ -30,8 +27,6 @@ class ButtonClickStyleView: UIView {
3027
3128
3229 var cornerRadius : CGFloat = 0.0
33- // var animationTypeValue: CGFloat?
34- var animationClickDuration : CGFloat ?
3530
3631
3732// var frontView: UIView?
@@ -50,14 +45,13 @@ class ButtonClickStyleView: UIView {
5045 }
5146
5247 let animVal : CGFloat ? = animationValue != 0.0 ? animationValue : nil
53- // let animDur: CGFloat? = animationDuration != 0.0 ? animationDuration : nil
48+ let animDur : CGFloat ? = animationDuration != 0.0 ? animationDuration : nil
5449
5550 self . state = . init(
5651 allSubviews: allSubviews,
5752 animationType: animationType,
5853 animationTypeValue: animVal,
59- startClick: startClick,
60- buttonColor: buttonColor
54+ animationDuration: animDur
6155 )
6256 }
6357 updateSubviews ( )
@@ -92,43 +86,14 @@ class ButtonClickStyleView: UIView {
9286 self . layer. cornerRadius = radius
9387 self . allSubviews = state. allSubviews
9488 self . animationType = state. animationType ?? 0
95- // self.animationTypeValue = state.animationTypeValue
96- self . buttonColor = state. buttonColor
9789 self . addViews = addViews
98- self . startClick = state. startClick
9990
10091
10192 if debugPrint { print ( " ------------------------------------------ " ) }
10293 if debugPrint { print ( " ButtonClickStyleView 🥶 init (STATE frame radius addViews) 🥶 \( self ) " ) }
10394
10495 }
10596
106- // public init(
107- // frame: CGRect,
108- // radius: CGFloat = 0.0,
109- // animation: Int = 0,
110- // allSubviews: Bool = true,
111- // value: CGFloat? = nil,
112- // duration: CGFloat? = nil,
113- // addViews: [UIView]? = nil,
114- // startClick: Bool = false
115- // ) {
116- // super.init(frame: frame)
117- // self.cornerRadius = radius
118- // self.allSubviews = allSubviews
119- // self.layer.cornerRadius = radius
120- // self.animationType = animation
121- // self.animationTypeValue = value
122- // self.animationClickDuration = duration
123- // self.addViews = addViews
124- // self.startClick = startClick
125- //
126- // if debugPrint { print(" ------------------------------------------") }
127- // if debugPrint { print(" ButtonClickStyleView 🥶 init (frame radius animation value duration addViews startClick) 🥶 \(self) ") }
128- //// updateSubviews()
129- // }
130-
131-
13297 // MARK: - Layout subViews Update
13398
13499
@@ -152,7 +117,7 @@ class ButtonClickStyleView: UIView {
152117 if setupDone { return }
153118 guard let state = state else { return }
154119
155- let style = ButtonClick . Style. getClick ( state: state)
120+ self . style = ButtonClick . Style. getClick ( state: state)
156121
157122 var onlyButtonReturn = true
158123 switch style. typeEasy ( ) {
@@ -180,12 +145,12 @@ class ButtonClickStyleView: UIView {
180145 }
181146
182147 func updateStartClick( ) {
183- if startClick {
184- startClick = false
185-
148+ // if startClick {
149+ // startClick = false
150+ //
186151 let nviews = getViews ( )
187- button? . onClick ( views: nviews, radius: cornerRadius, style: style, duration: animationClickDuration )
188- }
152+ button? . onClick ( views: nviews, radius: cornerRadius, style: style, duration: state ? . animationDuration )
153+ // }
189154 }
190155
191156 public func update( animationType: Int , allSubviews: Bool = true ) {
@@ -211,7 +176,6 @@ class ButtonClickStyleView: UIView {
211176 // MARK: - Set Animation Style
212177
213178 public func setAnimation( style: ButtonClick . Style , views: [ UIView ] ? = nil ) {
214- self . style = style
215179 // updateSubviews()
216180
217181 layer. cornerRadius = cornerRadius
@@ -239,20 +203,10 @@ class ButtonClickStyleView: UIView {
239203 // MARK: - Create Button
240204
241205
242-
243- // public func createFrontView() {
244- //
245- // let v = UIView(frame: bounds)
246- // v.backgroundColor = .clear
247- // v.clipsToBounds = false
248- // addSubview(v)
249- // self.frontView = v
250- // }
251-
252206 public func createButton( ) {
253207 let btn = UIButton ( type: . system)
254208 btn. frame = bounds
255- btn. backgroundColor = buttonColor ? UIColor . systemRed . withAlphaComponent ( 0.4 ) : . clear
209+ btn. backgroundColor = . clear
256210 btn. setTitle ( nil , for: . normal)
257211 btn. layer. cornerRadius = cornerRadius
258212 btn. clipsToBounds = true
0 commit comments