@@ -21,18 +21,18 @@ open class SSSpinnerButton: UIButton {
2121 internal var storedNormalTitle : String ?
2222 internal var storedSelectedTitle : String ?
2323 internal var storedDisableTitle : String ?
24- internal var storedHighlitedTitle : String ?
24+ internal var storedHighlightedTitle : String ?
2525
2626 public var rippleEffectAnimationDuration = 0.0
2727 public var initialOpacity = 0.0
2828 public var rippleEffectColor = UIColor . white
2929 public var rippleEffectPercent = CGFloat ( 0.0 )
30- public var initalRippleEffectPercent : CGFloat = CGFloat ( 0.0 )
30+ public var initialRippleEffectPercent : CGFloat = CGFloat ( 0.0 )
3131
3232 internal var storedAttributedNormalTitle : NSAttributedString ?
3333 internal var storedAttributedSelectedTitle : NSAttributedString ?
3434 internal var storedAttributedDisableTitle : NSAttributedString ?
35- internal var storedAttributedHighlitedTitle : NSAttributedString ?
35+ internal var storedAttributedHighlightedTitle : NSAttributedString ?
3636
3737 internal var storedBackgroundNormalImage : UIImage ?
3838 internal var storedBackgroundSelectedImage : UIImage ?
@@ -49,20 +49,17 @@ open class SSSpinnerButton: UIButton {
4949 fileprivate var isAnimating : Bool = false
5050
5151 fileprivate var spinnerType : SpinnerType = Config . spinnerType
52-
53- fileprivate var storedWidth : CGFloat ?
54- fileprivate var storedHeight : CGFloat ?
55-
52+
5653 /// Sets the button corner radius
57- @IBInspectable var cornrRadius : CGFloat = 0 {
54+ @IBInspectable var cornerRadius : CGFloat = 0 {
5855 willSet {
5956 layer. cornerRadius = newValue
6057 }
6158 }
6259 @IBInspectable var setRippleEffect : Bool = false {
6360 didSet {
6461 if setRippleEffect {
65- self . setRippleEffect ( rippleEffectAnimationDuration: 0.3 , initialOpacity: 0.5 , rippleEffectColor: rippleEffectColor, rippleEffectPercent: 0.45 , initalRippleEffectPercent : 0.3 )
62+ self . setRippleEffect ( rippleEffectAnimationDuration: 0.3 , initialOpacity: 0.5 , rippleEffectColor: rippleEffectColor, rippleEffectPercent: 0.45 , initialRippleEffectPercent : 0.3 )
6663 }
6764 }
6865 }
@@ -143,7 +140,7 @@ open class SSSpinnerButton: UIButton {
143140 }
144141
145142 /// Sets the button attributed title for its normal state
146- public var attributedHighlitedTitle : NSAttributedString ? {
143+ public var attributedHighlightedTitle : NSAttributedString ? {
147144 get {
148145 return self . attributedTitle ( for: . highlighted)
149146 } set {
@@ -179,12 +176,12 @@ open class SSSpinnerButton: UIButton {
179176
180177public extension SSSpinnerButton {
181178
182- func setRippleEffect( rippleEffectAnimationDuration: Double , initialOpacity: Double , rippleEffectColor: UIColor , rippleEffectPercent: CGFloat , initalRippleEffectPercent : CGFloat ) {
179+ func setRippleEffect( rippleEffectAnimationDuration: Double , initialOpacity: Double , rippleEffectColor: UIColor , rippleEffectPercent: CGFloat , initialRippleEffectPercent : CGFloat ) {
183180 self . rippleEffectAnimationDuration = rippleEffectAnimationDuration
184181 self . initialOpacity = initialOpacity
185182 self . rippleEffectColor = rippleEffectColor
186183 self . rippleEffectPercent = rippleEffectPercent
187- self . initalRippleEffectPercent = initalRippleEffectPercent
184+ self . initialRippleEffectPercent = initialRippleEffectPercent
188185 }
189186}
190187
@@ -199,7 +196,7 @@ public extension SSSpinnerButton{
199196 shapeLayer = CAShapeLayer ( )
200197 // let center = CGPoint(x: bounds.width/CGFloat(Constants.TWO), y: bounds.height/CGFloat(Constants.TWO))
201198 let diagnolLength = sqrt ( bounds. width*bounds. width + bounds. height*bounds. height)
202- let path = UIBezierPath ( arcCenter: touch. location ( in: self ) , radius: 0.5 * diagnolLength*initalRippleEffectPercent , startAngle: CGFloat ( 0 ) , endAngle: ( CGFloat ( Double ( 360 ) * . pi) / CGFloat( 180 ) ) , clockwise: true )
199+ let path = UIBezierPath ( arcCenter: touch. location ( in: self ) , radius: 0.5 * diagnolLength*initialRippleEffectPercent , startAngle: CGFloat ( 0 ) , endAngle: ( CGFloat ( Double ( 360 ) * . pi) / CGFloat( 180 ) ) , clockwise: true )
203200 shapeLayer. path = path. cgPath
204201 shapeLayer. opacity = Float ( initialOpacity)
205202 shapeLayer. fillColor = rippleEffectColor. cgColor
@@ -209,7 +206,7 @@ public extension SSSpinnerButton{
209206 layer. addSublayer ( shapeLayer)
210207 let circleEnlargeAnimation = CABasicAnimation ( keyPath: " transform.scale " )
211208 circleEnlargeAnimation. fromValue = 1
212- circleEnlargeAnimation. toValue = rippleEffectPercent/ initalRippleEffectPercent
209+ circleEnlargeAnimation. toValue = rippleEffectPercent/ initialRippleEffectPercent
213210 circleEnlargeAnimation. duration = Double ( rippleEffectAnimationDuration) * 0.7
214211 circleEnlargeAnimation. fillMode = CAMediaTimingFillMode . forwards
215212 circleEnlargeAnimation. isRemovedOnCompletion = false
@@ -240,18 +237,18 @@ private extension SSSpinnerButton {
240237 func setUp( ) {
241238
242239 self . removeAnimationLayer ( )
243- if self . cornrRadius == 0 {
244- self . cornrRadius = self . layer. cornerRadius
240+ if self . cornerRadius == 0 {
241+ self . cornerRadius = self . layer. cornerRadius
245242 }
246243 if layer. sublayers != nil {
247244
248245 for item in layer. sublayers! where item is CAGradientLayer {
249246
250- item. cornerRadius = self . cornrRadius
247+ item. cornerRadius = self . cornerRadius
251248 item. masksToBounds = true
252249 }
253250 }
254- self . layer. cornerRadius = self . cornrRadius
251+ self . layer. cornerRadius = self . cornerRadius
255252 self . layer. masksToBounds = true
256253
257254 if self . image ( for: . normal) != nil && self . normalTitle != nil {
@@ -285,8 +282,8 @@ public extension SSSpinnerButton {
285282 /// - spinnerSize: size of spinner layer
286283 /// - complete: complation block (call after animation start)
287284 func startAnimate( spinnerType: SpinnerType = Config . spinnerType, spinnercolor: UIColor = Config . spinnerColor, spinnerSize: UInt ? = nil , complete: ( ( ) -> Void ) ? ) {
288- if self . cornrRadius == 0 {
289- self . cornrRadius = self . layer. cornerRadius
285+ if self . cornerRadius == 0 {
286+ self . cornerRadius = self . layer. cornerRadius
290287 }
291288
292289 self . removeAnimationLayer ( )
@@ -368,7 +365,7 @@ private extension SSSpinnerButton {
368365 storedDisableTitle = disabledTitle
369366 disabledTitle = nil
370367
371- storedHighlitedTitle = highlightedTitle
368+ storedHighlightedTitle = highlightedTitle
372369 highlightedTitle = nil
373370
374371 storedAttributedNormalTitle = attributedNormalTitle
@@ -380,8 +377,8 @@ private extension SSSpinnerButton {
380377 storedAttributedDisableTitle = attributedDisableTitle
381378 attributedDisableTitle = nil
382379
383- storedAttributedHighlitedTitle = attributedHighlitedTitle
384- attributedHighlitedTitle = nil
380+ storedAttributedHighlightedTitle = attributedHighlightedTitle
381+ attributedHighlightedTitle = nil
385382
386383
387384 storedBackgroundNormalImage = self . backgroundImage ( for: . normal)
@@ -395,28 +392,25 @@ private extension SSSpinnerButton {
395392 storedHighlightedImage = self . image ( for: . highlighted)
396393
397394 storedBackgroundColor = self . backgroundColor
398- storedWidth = frame. width
399- storedHeight = frame. height
400-
401395 self . setImage ( nil , for: . normal)
402396 self . setImage ( nil , for: . disabled)
403397 self . setImage ( nil , for: . selected)
404398 self . setImage ( nil , for: . highlighted)
405399 isUserInteractionEnabled = false
406400
407- let animaton = CABasicAnimation ( keyPath: " bounds.size.width " )
408- animaton . fromValue = bounds. width
409- animaton . toValue = bounds. height
410- animaton . duration = animationDuration
411- animaton . fillMode = CAMediaTimingFillMode . both
412- animaton . isRemovedOnCompletion = false
401+ let animation = CABasicAnimation ( keyPath: " bounds.size.width " )
402+ animation . fromValue = bounds. width
403+ animation . toValue = bounds. height
404+ animation . duration = animationDuration
405+ animation . fillMode = CAMediaTimingFillMode . both
406+ animation . isRemovedOnCompletion = false
413407 if layer. sublayers != nil {
414408
415409 for item in layer. sublayers! where item is CAGradientLayer {
416- item. add ( animaton , forKey: animaton . keyPath)
410+ item. add ( animation , forKey: animation . keyPath)
417411 }
418412 }
419- layer. add ( animaton , forKey: animaton . keyPath)
413+ layer. add ( animation , forKey: animation . keyPath)
420414 self . perform ( #selector( startSpinner) , with: nil , afterDelay: animationDuration)
421415
422416 DispatchQueue . main. asyncAfter ( deadline: . now( ) + animationDuration, execute: {
@@ -480,7 +474,7 @@ private extension SSSpinnerButton {
480474 self . setTitle ( self . storedNormalTitle, for: . normal)
481475 self . setTitle ( self . storedSelectedTitle, for: . selected)
482476 self . setTitle ( self . storedDisableTitle, for: . disabled)
483- self . setTitle ( self . storedHighlitedTitle , for: . highlighted)
477+ self . setTitle ( self . storedHighlightedTitle , for: . highlighted)
484478
485479 if self . storedAttributedNormalTitle != nil {
486480 self . setAttributedTitle ( self . storedAttributedNormalTitle, for: . normal)
@@ -494,8 +488,8 @@ private extension SSSpinnerButton {
494488 self . setAttributedTitle ( self . storedAttributedDisableTitle, for: . disabled)
495489 }
496490
497- if self . storedAttributedHighlitedTitle != nil {
498- self . setAttributedTitle ( self . storedAttributedHighlitedTitle , for: . highlighted)
491+ if self . storedAttributedHighlightedTitle != nil {
492+ self . setAttributedTitle ( self . storedAttributedHighlightedTitle , for: . highlighted)
499493 }
500494
501495 self . setBackgroundImage ( self . storedBackgroundNormalImage, for: . normal)
@@ -509,8 +503,6 @@ private extension SSSpinnerButton {
509503 self . isUserInteractionEnabled = true
510504
511505 let animation = CABasicAnimation ( keyPath: " bounds.size.width " )
512- animation. fromValue = storedHeight
513- animation. toValue = storedWidth
514506 animation. duration = self . animationDuration
515507 animation. fillMode = CAMediaTimingFillMode . forwards
516508 animation. isRemovedOnCompletion = false
@@ -520,11 +512,11 @@ private extension SSSpinnerButton {
520512
521513 for item in self . layer. sublayers! where item is CAGradientLayer {
522514 item. add ( animation, forKey: animation. keyPath)
523- item. cornerRadius = self . cornrRadius
515+ item. cornerRadius = self . cornerRadius
524516 }
525517 }
526518 self . isAnimating = false
527- self . layer. cornerRadius = self . cornrRadius
519+ self . layer. cornerRadius = self . cornerRadius
528520 if complete != nil {
529521 complete!( )
530522 }
0 commit comments