-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from SimformSolutionsPvtLtd/develop
Develop
- Loading branch information
Showing
14 changed files
with
433 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
SSSpinnerButton/SpinerShapes/SpinnerShapeWithAnimation/SSCircleScaleMultiple.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// SSCirclePulse.swift | ||
// SSSpinnerButton | ||
// | ||
// Created by Pranay Patel on 16/04/21. | ||
// Copyright © 2021 Simform Solutions. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class SSCircleScaleMultiple: SSSpinnerAnimationDelegate { | ||
|
||
/// setup spinner layer | ||
/// | ||
/// - Parameters: | ||
/// - layer: layer Parent layer (Button layer) | ||
/// - frame: frame of parant layer | ||
/// - color: color of spinner | ||
/// - spinnerSize: size of spinner layer | ||
func setupSpinnerAnimation(layer: CALayer, frame: CGRect, color: UIColor, spinnerSize: UInt?) { | ||
let sizeValue = min(frame.width, frame.height) | ||
let center = CGPoint(x: 0, y: 0) | ||
let duration: CFTimeInterval = 1 | ||
let beginTime = CACurrentMediaTime() | ||
let beginTimes = [0, 0.2, 0.4] | ||
|
||
// Scale animation | ||
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale") | ||
|
||
scaleAnimation.duration = duration | ||
scaleAnimation.fromValue = 0 | ||
scaleAnimation.toValue = 1 | ||
|
||
// Opacity animation | ||
let opacityAnimation = CAKeyframeAnimation(keyPath: "opacity") | ||
opacityAnimation.duration = duration | ||
opacityAnimation.keyTimes = [0, 0.05, 1] | ||
opacityAnimation.values = [0, 1, 0] | ||
|
||
// Animation | ||
let animation = CAAnimationGroup() | ||
|
||
animation.animations = [scaleAnimation, opacityAnimation] | ||
animation.timingFunction = CAMediaTimingFunction(name: .linear) | ||
animation.duration = duration | ||
animation.repeatCount = HUGE | ||
animation.isRemovedOnCompletion = false | ||
|
||
// Draw balls | ||
for i in 0 ..< 3 { | ||
let circle = SpinnerShape.circle.layerWith(size: CGSize(width: sizeValue, height: sizeValue), color: color) | ||
let frame = CGRect(x: center.x, y: center.y, width: sizeValue, height: sizeValue) | ||
animation.beginTime = beginTime + beginTimes[i] | ||
circle.frame = frame | ||
circle.opacity = 0 | ||
circle.add(animation, forKey: "animation") | ||
layer.addSublayer(circle) | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
SSSpinnerButton/SpinerShapes/SpinnerShapeWithAnimation/SSCircleWaveSpin.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// SSCircleWave.swift | ||
// SSSpinnerButton | ||
// | ||
// Created by Pranay Patel on 16/04/21. | ||
// Copyright © 2021 Simform Solutions. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class SSCircleWaveSpin: SSSpinnerAnimationDelegate { | ||
|
||
/// setup spinner layer | ||
/// | ||
/// - Parameters: | ||
/// - layer: layer Parent layer (Button layer) | ||
/// - frame: frame of parant layer | ||
/// - color: color of spinner | ||
/// - spinnerSize: size of spinner | ||
var pulseLayers = [CAShapeLayer]() | ||
|
||
func setupSpinnerAnimation(layer: CALayer, frame: CGRect, color: UIColor, spinnerSize: UInt?) { | ||
for _ in 0...3 { | ||
let pulseLayerPath = UIBezierPath(arcCenter: .zero, radius: CGFloat(spinnerSize ?? 0) , startAngle: CGFloat(0), endAngle: CGFloat(Double.pi * 2), clockwise: true) | ||
let pulseLayer = SpinnerLayers() | ||
pulseLayer.path = pulseLayerPath.cgPath | ||
pulseLayer.lineWidth = 1.0 | ||
pulseLayer.fillColor = UIColor.clear.cgColor | ||
pulseLayer.lineCap = CAShapeLayerLineCap.round | ||
pulseLayer.position = CGPoint(x: CGFloat(spinnerSize ?? 0) , y: CGFloat(spinnerSize ?? 0)) | ||
layer.addSublayer(pulseLayer) | ||
pulseLayers.append(pulseLayer) | ||
} | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | ||
self.animation(index: 0, color: color) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { | ||
self.animation(index: 1, color: color) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { | ||
self.animation(index: 2, color: color) | ||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { | ||
self.animation(index: 3, color: color) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func animation(index: Int, color: UIColor) { | ||
pulseLayers[index].strokeColor = color.cgColor | ||
let animation = CABasicAnimation(keyPath: "transform.scale") | ||
animation.duration = 1.5 | ||
animation.toValue = 0.9 | ||
animation.fromValue = 0.0 | ||
animation.timingFunction = CAMediaTimingFunction(name: .easeOut) | ||
animation.repeatCount = .infinity | ||
pulseLayers[index].add(animation, forKey: "scale") | ||
|
||
let opacityAnimation = CABasicAnimation(keyPath: #keyPath(CALayer.opacity)) | ||
opacityAnimation.duration = 2.0 | ||
opacityAnimation.toValue = 0.0 | ||
opacityAnimation.fromValue = 0.9 | ||
opacityAnimation.timingFunction = CAMediaTimingFunction(name: .easeOut) | ||
opacityAnimation.repeatCount = .infinity | ||
pulseLayers[index].add(animation, forKey: "opacity") | ||
} | ||
} |
Oops, something went wrong.