diff --git a/.swift-version b/.swift-version
new file mode 100644
index 0000000..5186d07
--- /dev/null
+++ b/.swift-version
@@ -0,0 +1 @@
+4.0
diff --git a/ButtonProgressBar-iOS.podspec b/ButtonProgressBar-iOS.podspec
index 4f3f18c..b2061ca 100644
--- a/ButtonProgressBar-iOS.podspec
+++ b/ButtonProgressBar-iOS.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'ButtonProgressBar-iOS'
- s.version = '0.1.2'
+ s.version = '1.0.1'
s.summary = 'A simple progress bar UIButton subclass.'
# This description is used to generate tags and improve search results.
@@ -24,13 +24,13 @@ Text enlarge on tap. Animated completion image.
DESC
s.homepage = 'https://github.com/thePsguy/ButtonProgressBar-iOS'
- # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
+ s.screenshots = 'https://raw.githubusercontent.com/thePsguy/ButtonProgressBar-iOS/master/output_F2Ryon.gif', 'https://raw.githubusercontent.com/thePsguy/ButtonProgressBar-iOS/master/preview.gif'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Pushkar Sharma' => 'thePsguy@icloud.com' }
s.source = { :git => 'https://github.com/thePsguy/ButtonProgressBar-iOS.git', :tag => s.version.to_s }
- # s.social_media_url = 'https://twitter.com/thePsguy'
+ s.social_media_url = 'https://twitter.com/thePsguy'
s.ios.deployment_target = '8.0'
- s.source_files = 'ButtonProgressBar-iOS/Classes/**/*'
+ s.source_files = 'Source/*.swift'
end
diff --git a/ButtonProgressBar-iOS/Assets/.gitkeep b/ButtonProgressBar-iOS/Assets/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/ButtonProgressBar-iOS/Classes/.gitkeep b/ButtonProgressBar-iOS/Classes/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/Example/ButtonProgressBar-iOS.xcodeproj/project.pbxproj b/Example/ButtonProgressBar-iOS.xcodeproj/project.pbxproj
index e4ba7d7..e98b8ce 100644
--- a/Example/ButtonProgressBar-iOS.xcodeproj/project.pbxproj
+++ b/Example/ButtonProgressBar-iOS.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
DD6EABDC5BD83ECE916983F6 /* Pods_ButtonProgressBar_iOS_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89FCD7F88F888CDC1653FECD /* Pods_ButtonProgressBar_iOS_Tests.framework */; };
+ F7032A3BA75C19B93C804BE6 /* Pods_ButtonProgressBar_iOS_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 117EDF792490C75FC8A1202D /* Pods_ButtonProgressBar_iOS_Example.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -56,6 +57,7 @@
buildActionMask = 2147483647;
files = (
4D7D54FD1E9EB1F500FA7BA3 /* ButtonProgressBar_iOS.framework in Frameworks */,
+ F7032A3BA75C19B93C804BE6 /* Pods_ButtonProgressBar_iOS_Example.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -217,11 +219,14 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
- LastSwiftMigration = 0820;
+ DevelopmentTeam = V6JUB3D3PN;
+ LastSwiftMigration = 0900;
+ ProvisioningStyle = Automatic;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
- LastSwiftMigration = 0820;
+ DevelopmentTeam = V6JUB3D3PN;
+ LastSwiftMigration = 0900;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
@@ -287,13 +292,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-ButtonProgressBar-iOS_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
4F452ECD7570C7BCBDC81498 /* [CP] Embed Pods Frameworks */ = {
@@ -302,9 +310,12 @@
files = (
);
inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-ButtonProgressBar-iOS_Example/Pods-ButtonProgressBar-iOS_Example-frameworks.sh",
+ "${BUILT_PRODUCTS_DIR}/ButtonProgressBar-iOS/ButtonProgressBar_iOS.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ButtonProgressBar_iOS.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -332,13 +343,16 @@
files = (
);
inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-ButtonProgressBar-iOS_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
EB4A715E786F7E826511F6F6 /* [CP] Copy Pods Resources */ = {
@@ -498,12 +512,15 @@
baseConfigurationReference = 89CA383809FFA3A8C232F51C /* Pods-ButtonProgressBar-iOS_Example.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ DEVELOPMENT_TEAM = V6JUB3D3PN;
INFOPLIST_FILE = "ButtonProgressBar-iOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
- PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
+ PRODUCT_BUNDLE_IDENTIFIER = "net.thepsguy.demo.ButtonProgressBar-iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -512,12 +529,15 @@
baseConfigurationReference = 037631BC6A9226892B5CFE90 /* Pods-ButtonProgressBar-iOS_Example.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ DEVELOPMENT_TEAM = V6JUB3D3PN;
INFOPLIST_FILE = "ButtonProgressBar-iOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
- PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
+ PRODUCT_BUNDLE_IDENTIFIER = "net.thepsguy.demo.ButtonProgressBar-iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
@@ -525,6 +545,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BE5984450B18F616883124C8 /* Pods-ButtonProgressBar-iOS_Tests.debug.xcconfig */;
buildSettings = {
+ DEVELOPMENT_TEAM = V6JUB3D3PN;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
@@ -537,7 +558,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Debug;
};
@@ -545,6 +567,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = B1CAFE402C8B22A5A9234201 /* Pods-ButtonProgressBar-iOS_Tests.release.xcconfig */;
buildSettings = {
+ DEVELOPMENT_TEAM = V6JUB3D3PN;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
@@ -553,7 +576,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 3.0;
+ SWIFT_SWIFT3_OBJC_INFERENCE = On;
+ SWIFT_VERSION = 4.0;
};
name = Release;
};
diff --git a/Example/ButtonProgressBar-iOS/ViewController.swift b/Example/ButtonProgressBar-iOS/ViewController.swift
index a5fcca1..6d96345 100644
--- a/Example/ButtonProgressBar-iOS/ViewController.swift
+++ b/Example/ButtonProgressBar-iOS/ViewController.swift
@@ -51,13 +51,13 @@ class ViewController: UIViewController {
timePeriod.textAlignment = .center
timePeriod.keyboardType = .numberPad
timePeriod.borderStyle = .roundedRect
- timePeriod.attributedPlaceholder = NSAttributedString(string: "Time Period", attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 9)])
+ timePeriod.attributedPlaceholder = NSAttributedString(string: "Time Period", attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 9)])
timePadding = UITextField(frame: CGRect(x: self.view.frame.width / 2 - 36, y: 145, width: 72, height: 18))
timePadding.textAlignment = .center
timePadding.keyboardType = .numberPad
timePadding.borderStyle = .roundedRect
- timePadding.attributedPlaceholder = NSAttributedString(string: "Padding Time", attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 8)])
+ timePadding.attributedPlaceholder = NSAttributedString(string: "Padding Time", attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 8)])
self.view.addSubview(completionButton)
self.view.addSubview(timePadding)
@@ -66,11 +66,11 @@ class ViewController: UIViewController {
self.view.addSubview(progressButton)
}
- func progressComplete(sender: AnyObject?) {
+ @objc func progressComplete(sender: AnyObject?) {
progressButton.triggerCompletion()
}
- func tapped(){
+ @objc func tapped(){
let time = Double(timePeriod.text != "" ? timePeriod.text! : "1")!
let padding = Double(timePadding.text != "" ? timePadding.text! : "0.5")!
picker.selectedRow(inComponent: 0) == 0 ? self.progressButton.startIndeterminate(withTimePeriod: time, andTimePadding: padding) : self.loadDeterminate()
@@ -87,7 +87,7 @@ class ViewController: UIViewController {
RunLoop.current.add(timer, forMode: .defaultRunLoopMode)
}
- func animateDeterminate(sender: Timer) {
+ @objc func animateDeterminate(sender: Timer) {
if self.progressButton.progress >= 1.0 {
sender.invalidate()
}
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..589b45e
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,5 @@
+import PackageDescription
+
+let package = Package(
+ name: "ButtonProgressBar_iOS"
+)
diff --git a/README.md b/README.md
index bb9f6d5..0b4e0e7 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,19 @@
# ButtonProgressBar-iOS
-[](https://travis-ci.org/thePsguy/ButtonProgressBar-iOS)
[](http://cocoapods.org/pods/ButtonProgressBar-iOS)
[](http://cocoapods.org/pods/ButtonProgressBar-iOS)
[](http://cocoapods.org/pods/ButtonProgressBar-iOS)
+[](https://twitter.com/thePsguy)
-
## Example
-To run the example project, clone the repo, and run `pod install` from the Example directory first.
+* For LIVE PREVIEW on Appetize in your browser itself, [click here](https://appetize.io/app/rcb15cyg78agt90pqa3xujx3cc).
+
+* To run the example project, clone the repo, and run `pod install` from the Example directory first.
+
+
## Requirements
iOS > 7.0
@@ -21,7 +24,7 @@ ButtonProgressBar-iOS is available through [CocoaPods](http://cocoapods.org). To
it, simply add the following line to your Podfile:
```ruby
-pod "ButtonProgressBar-iOS"
+pod 'ButtonProgressBar-iOS'
```
## Usage
diff --git a/SimulatorScreenShot.png b/SimulatorScreenShot.png
new file mode 100644
index 0000000..a692133
Binary files /dev/null and b/SimulatorScreenShot.png differ
diff --git a/ButtonProgressBar-iOS/Classes/ButtonProgressBar.swift b/Source/ButtonProgressBar.swift
similarity index 76%
rename from ButtonProgressBar-iOS/Classes/ButtonProgressBar.swift
rename to Source/ButtonProgressBar.swift
index 278e26e..438dca5 100644
--- a/ButtonProgressBar-iOS/Classes/ButtonProgressBar.swift
+++ b/Source/ButtonProgressBar.swift
@@ -1,10 +1,24 @@
-//
-// ButtonProgressBar.swift
-// ButtonProgressBar-iOS
-//
-// Created by Pushkar Sharma on 08/04/2017.
-// Copyright © 2017 thePsguy. All rights reserved.
-//
+/*
+Copyright (c) 2017 Pushkar Sharma
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
import UIKit
@@ -53,6 +67,35 @@ public class ButtonProgressBar: UIButton {
self.bringSubview(toFront: imageView!)
}
+ required public init?(coder aDecoder: NSCoder) {
+ super.init(coder: aDecoder)
+
+ layer.cornerRadius = cornerRadius
+ layer.masksToBounds = true
+ backgroundColor = UIColor(red: 50/255, green: 100/255, blue: 200/255, alpha: 1.0)
+
+ titleLabel!.textAlignment = .center
+ titleLabel!.textColor = .white
+ titleLabel!.font = UIFont.boldSystemFont(ofSize: 0)
+
+ imageView?.contentMode = .center
+ imageView?.tintColor = .white
+ self.hideImage(true)
+
+ let rectanglePath = UIBezierPath(rect: CGRect(x: 0, y: 0, width: frame.width, height: frame.height))
+
+ progressLayer.path = rectanglePath.cgPath
+ progressLayer.fillColor = UIColor.clear.cgColor
+ progressLayer.strokeColor = progressColor.cgColor
+
+ progressLayer.strokeEnd = 0.0
+ progressLayer.lineWidth = frame.height*2
+
+ layer.addSublayer(progressLayer)
+ self.bringSubview(toFront: titleLabel!)
+ self.bringSubview(toFront: imageView!)
+ }
+
/**
Used to handle indeterminate loading.
- Parameter timePeriod (optional): The total time (animation + padding, default 2.0) that 1 cycle of the loading takes.
@@ -70,7 +113,7 @@ public class ButtonProgressBar: UIButton {
RunLoop.current.add(timer!, forMode: .defaultRunLoopMode)
}
- func animateIndeterminate(sender: Timer) {
+ @objc func animateIndeterminate(sender: Timer) {
let time = sender.timeInterval - (sender.userInfo as! Double)
let stroke = CABasicAnimation(keyPath: "strokeEnd")
stroke.fromValue = 0.0
@@ -99,10 +142,6 @@ public class ButtonProgressBar: UIButton {
self.setProgress(progress: 0.0, false)
}
- required public init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
override public func layoutSubviews() {
super.layoutSubviews()
titleLabel!.frame = self.bounds
@@ -155,7 +194,7 @@ public class ButtonProgressBar: UIButton {
self.imageView?.layer.removeAllAnimations()
imageView?.layer.transform = CATransform3DMakeScale(0.0, 0.0, 0.0)
} else {
- var completionAnim = CABasicAnimation()
+ let completionAnim = CABasicAnimation()
completionAnim.keyPath = "transform"
completionAnim.fromValue = CATransform3DMakeScale(0.0, 0.0, 0.0)
completionAnim.toValue = CATransform3DIdentity
diff --git a/_Pods.xcodeproj b/_Pods.xcodeproj
deleted file mode 120000
index 3c5a8e7..0000000
--- a/_Pods.xcodeproj
+++ /dev/null
@@ -1 +0,0 @@
-Example/Pods/Pods.xcodeproj
\ No newline at end of file