Skip to content

Commit

Permalink
Merge pull request #38 from SimformSolutionsPvtLtd/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mobile-simformsolutions authored Nov 2, 2022
2 parents 830d736 + 5d8baa7 commit cc9c4b8
Show file tree
Hide file tree
Showing 14 changed files with 433 additions and 66 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SSspinnerButton
# SSSpinnerButton


SSSpinnerButton is an elegant button with a different spinner animations.
Expand Down Expand Up @@ -33,10 +33,10 @@ SSSpinnerButton is an elegant button with a different spinner animations.
-
import UIKit
import SSSpinnerButton

**Carthage**

Add `github simformsolutions/SSSpinnerButton` to your project's Cartfile

**Carthage**

Add `github simformsolutions/SSSpinnerButton` to your project's Cartfile

**Manually**
- Download and drop **SSSpinnerButton** folder in your project.
Expand Down
14 changes: 8 additions & 6 deletions SSSpinnerButton Demo/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<viewController modalPresentationStyle="fullScreen" id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
167 changes: 123 additions & 44 deletions SSSpinnerButton Demo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SSSpinnerButton Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ViewController: UIViewController {

@IBAction func onSpinnnerButtonClick(_ sender: SSSpinnerButton) {
sender.isSelected = !sender.isSelected
let arr: [SpinnerType] = [.ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .circleStrokeSpin, .ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .circleStrokeSpin]
let arr: [SpinnerType] = [.ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .circleStrokeSpin, .ballClipRotate, .ballSpinFade, .lineSpinFade, .ballRotateChase, .pacman, .circleScaleMultiple, .circleWaveSpin]

// MARK: Start Animating
sender.startAnimate(spinnerType: arr[sender.tag], spinnercolor: .white, spinnerSize: 20, complete: nil)
Expand Down
2 changes: 1 addition & 1 deletion SSSpinnerButton.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "SSSpinnerButton"
s.version = "3.0.2"
s.version = "3.1.0"
s.summary = "SSSpinnerButton is an elegant button with a different spinner animations."

#s.description = "SSSpinnerButton is an elegant button with a different spinner animations."
Expand Down
32 changes: 25 additions & 7 deletions SSSpinnerButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
07FAD2B022A06F7E00FC1F9E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 07FAD2A922A06F7E00FC1F9E /* Main.storyboard */; };
07FAD2B122A06F7E00FC1F9E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07FAD2AB22A06F7E00FC1F9E /* AppDelegate.swift */; };
51AAA60420C65EA5000F4BCD /* .tailor.yml in Resources */ = {isa = PBXBuildFile; fileRef = 51AAA60320C65EA5000F4BCD /* .tailor.yml */; };
D346F19628242F900085293D /* SSPacman.swift in Sources */ = {isa = PBXBuildFile; fileRef = D346F19528242F900085293D /* SSPacman.swift */; };
D346F19828242FD60085293D /* SSCircleScaleMultiple.swift in Sources */ = {isa = PBXBuildFile; fileRef = D346F19728242FD60085293D /* SSCircleScaleMultiple.swift */; };
D3D692F22629BDFD0032EB92 /* SSCircleWaveSpin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D692F12629BDFD0032EB92 /* SSCircleWaveSpin.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -82,6 +85,9 @@
730FA84E2136AD4800F6116F /* SSSuccessMark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSSuccessMark.swift; sourceTree = "<group>"; };
737852F82137B12B005A1EA6 /* SSErrorMark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSErrorMark.swift; sourceTree = "<group>"; };
737852FA2137C745005A1EA6 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
D346F19528242F900085293D /* SSPacman.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSPacman.swift; sourceTree = "<group>"; };
D346F19728242FD60085293D /* SSCircleScaleMultiple.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSCircleScaleMultiple.swift; path = ../../../../../../Desktop/SSSpinnerButton/SSSpinnerButton/SpinerShapes/SpinnerShapeWithAnimation/SSCircleScaleMultiple.swift; sourceTree = "<group>"; };
D3D692F12629BDFD0032EB92 /* SSCircleWaveSpin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSCircleWaveSpin.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -173,11 +179,14 @@
519BCB67219A946600F50E26 /* SSFailMark.swift */,
51AAA5F120C64EF0000F4BCD /* SSBallRotateChase.swift */,
51AAA5F220C64EF0000F4BCD /* SSBallSpinFadeLoader.swift */,
D346F19728242FD60085293D /* SSCircleScaleMultiple.swift */,
51AAA5F320C64EF0000F4BCD /* SSCircleStrokeSpin.swift */,
51AAA5F420C64EF0000F4BCD /* SSLineSpinFadeLoader.swift */,
51AAA5F520C64EF0000F4BCD /* SSSpinnerBallClipRotate.swift */,
730FA84E2136AD4800F6116F /* SSSuccessMark.swift */,
737852F82137B12B005A1EA6 /* SSErrorMark.swift */,
D346F19528242F900085293D /* SSPacman.swift */,
D3D692F12629BDFD0032EB92 /* SSCircleWaveSpin.swift */,
);
path = SpinnerShapeWithAnimation;
sourceTree = "<group>";
Expand Down Expand Up @@ -259,7 +268,7 @@
51AAA5D420C64ED3000F4BCD = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -325,14 +334,17 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D346F19828242FD60085293D /* SSCircleScaleMultiple.swift in Sources */,
07FAD29E22A0679B00FC1F9E /* SSSuccessMark.swift in Sources */,
07FAD2A022A067A300FC1F9E /* SpinnerTypes.swift in Sources */,
07FAD29822A0678800FC1F9E /* SSFailMark.swift in Sources */,
07FAD2A222A067AC00FC1F9E /* SSSpinnerButton.swift in Sources */,
07FAD29A22A0678E00FC1F9E /* SSBallSpinFadeLoader.swift in Sources */,
07FAD29B22A0679200FC1F9E /* SSCircleStrokeSpin.swift in Sources */,
07FAD29722A0678300FC1F9E /* spinnerShape.swift in Sources */,
D3D692F22629BDFD0032EB92 /* SSCircleWaveSpin.swift in Sources */,
07FAD29D22A0679800FC1F9E /* SSSpinnerBallClipRotate.swift in Sources */,
D346F19628242F900085293D /* SSPacman.swift in Sources */,
07FAD29C22A0679500FC1F9E /* SSLineSpinFadeLoader.swift in Sources */,
07FAD2A122A067A600FC1F9E /* Extensions.swift in Sources */,
07FAD29922A0678A00FC1F9E /* SSBallRotateChase.swift in Sources */,
Expand Down Expand Up @@ -581,13 +593,15 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y98X8JAPH6;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/SSSpinnerButton/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.simform.SSSpinnerButtonDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -598,13 +612,15 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y98X8JAPH6;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/SSSpinnerButton/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.simform.SSSpinnerButtonDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -675,13 +691,15 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Y98X8JAPH6;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/SSSpinnerButton/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.simform.SSSpinnerButtonDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
10 changes: 10 additions & 0 deletions SSSpinnerButton/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiresFullScreen</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
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)
}
}
}
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")
}
}
Loading

0 comments on commit cc9c4b8

Please sign in to comment.