Skip to content

Commit 87501be

Browse files
Merge pull request #52 from SimformSolutionsPvtLtd/develop
Develop
2 parents e4da07a + 1cd8a23 commit 87501be

File tree

9 files changed

+47
-70
lines changed

9 files changed

+47
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ SSSpinnerButton is a versatile library for iOS developers, written in Swift, tha
8181
8282
**To Change the RippleEffect**
8383

84-
button.setRippleEffect(rippleEffectAnimationDuration: Double, initialOpacity: Double, rippleEffectColor: UIColor, rippleEffectPercent: Double, initalRippleEffectPercent: Double)
84+
button.setRippleEffect(rippleEffectAnimationDuration: Double, initialOpacity: Double, rippleEffectColor: UIColor, rippleEffectPercent: Double, initialRippleEffectPercent: Double)
8585

8686
# Migration
8787
**Version 3.0.1**

SSSpinnerButton Demo/Base.lproj/Main.storyboard

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
3737
</state>
3838
<userDefinedRuntimeAttributes>
39-
<userDefinedRuntimeAttribute type="number" keyPath="cornrRadius">
39+
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
4040
<real key="value" value="10"/>
4141
</userDefinedRuntimeAttribute>
4242
</userDefinedRuntimeAttributes>
@@ -238,24 +238,6 @@
238238
</objects>
239239
<point key="canvasLocation" x="1608.6956521739132" y="21.428571428571427"/>
240240
</scene>
241-
<!--View Controller-->
242-
<scene sceneID="vFC-gR-D9D">
243-
<objects>
244-
<viewController modalPresentationStyle="fullScreen" id="mLP-3M-IlK" sceneMemberID="viewController">
245-
<layoutGuides>
246-
<viewControllerLayoutGuide type="top" id="Z0W-Nf-uIL"/>
247-
<viewControllerLayoutGuide type="bottom" id="hMo-eG-eFa"/>
248-
</layoutGuides>
249-
<view key="view" contentMode="scaleToFill" id="Olu-jz-NGk">
250-
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
251-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
252-
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
253-
</view>
254-
</viewController>
255-
<placeholder placeholderIdentifier="IBFirstResponder" id="3Jl-aI-SX3" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
256-
</objects>
257-
<point key="canvasLocation" x="-443" y="144"/>
258-
</scene>
259241
<!--Navigation Controller-->
260242
<scene sceneID="AlF-cJ-MGF">
261243
<objects>

SSSpinnerButton Demo/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ViewController: UIViewController {
2121

2222
override func viewDidLoad() {
2323
super.viewDidLoad()
24-
btnRippleEffect.setRippleEffect(rippleEffectAnimationDuration: 0.3, initialOpacity: 0.5, rippleEffectColor: .black, rippleEffectPercent: 0.45, initalRippleEffectPercent: 0.3)
24+
btnRippleEffect.setRippleEffect(rippleEffectAnimationDuration: 0.3, initialOpacity: 0.5, rippleEffectColor: .black, rippleEffectPercent: 0.45, initialRippleEffectPercent: 0.3)
2525
// Do any additional setup after loading the view, typically from a nib.
2626
}
2727

SSSpinnerButton.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "SSSpinnerButton"
11-
s.version = "3.2.0"
11+
s.version = "3.2.1"
1212
s.summary = "SSSpinnerButton is an elegant button with a different spinner animations."
1313

1414
#s.description = "SSSpinnerButton is an elegant button with a different spinner animations."

SSSpinnerButton/Info.plist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
<false/>
2727
<key>UISupportedInterfaceOrientations</key>
2828
<array>
29+
<string>UIInterfaceOrientationLandscapeLeft</string>
30+
<string>UIInterfaceOrientationLandscapeRight</string>
2931
<string>UIInterfaceOrientationPortrait</string>
32+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
3033
</array>
3134
</dict>
3235
</plist>

SSSpinnerButton/SpinerShapes/SpinnerAnimationDelegate/SpinnerAnimationDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
import UIKit
1111

1212
///
13-
protocol SSSpinnerAnimationDelegate {
13+
protocol SSSpinnerAnimationDelegate: AnyObject {
1414

1515
/// setup spinner layer
1616
///

SSSpinnerButton/SpinerShapes/SpinnerShapeWithAnimation/SSBallRotateChase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SSBallRotateChase: SSSpinnerAnimationDelegate {
7676
positionAnimation.repeatCount = HUGE
7777
positionAnimation.path = UIBezierPath(arcCenter: CGPoint(x: x, y: y), radius: size.width / 2, startAngle: CGFloat(3 * Double.pi * 0.5), endAngle: CGFloat(3 * Double.pi * 0.5 + 2 * Double.pi), clockwise: true).cgPath
7878

79-
// Aniamtion
79+
// Animation
8080
let animation = CAAnimationGroup()
8181
animation.animations = [scaleAnimation, positionAnimation]
8282
animation.timingFunction = timeFunc

SSSpinnerButton/SpinerShapes/SpinnerShapeWithAnimation/SSBallSpinFadeLoader.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ class SSBallSpinFadeLoader: SSSpinnerAnimationDelegate {
4343
scaleAnimation.duration = duration
4444

4545
// Opacity animation
46-
let opacityAnimaton = CAKeyframeAnimation(keyPath: "opacity")
46+
let opacityAnimation = CAKeyframeAnimation(keyPath: "opacity")
4747

48-
opacityAnimaton.keyTimes = [0, 0.5, 1]
49-
opacityAnimaton.values = [1, 0.3, 1]
50-
opacityAnimaton.duration = duration
48+
opacityAnimation.keyTimes = [0, 0.5, 1]
49+
opacityAnimation.values = [1, 0.3, 1]
50+
opacityAnimation.duration = duration
5151

5252
// Animation
5353
let animation = CAAnimationGroup()
5454

55-
animation.animations = [scaleAnimation, opacityAnimaton]
55+
animation.animations = [scaleAnimation, opacityAnimation]
5656
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear)
5757
animation.duration = duration
5858
animation.repeatCount = HUGE

SSSpinnerButton/SpinnerButton/SSSpinnerButton.swift

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

180177
public 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

Comments
 (0)