diff --git a/JNJProgressButton-Sample.xcodeproj/project.pbxproj b/JNJProgressButton-Sample.xcodeproj/project.pbxproj
index 63d2820..77715b1 100644
--- a/JNJProgressButton-Sample.xcodeproj/project.pbxproj
+++ b/JNJProgressButton-Sample.xcodeproj/project.pbxproj
@@ -192,6 +192,11 @@
CLASSPREFIX = JNJ;
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = JNJ;
+ TargetAttributes = {
+ A464A211177E9DB600BCE741 = {
+ DevelopmentTeam = WQWKS8U593;
+ };
+ };
};
buildConfigurationList = A464A20D177E9DB600BCE741 /* Build configuration list for PBXProject "JNJProgressButton-Sample" */;
compatibilityVersion = "Xcode 3.2";
@@ -315,6 +320,7 @@
A464A230177E9DB600BCE741 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JNJProgressButton-Sample/JNJProgressButton-Sample-Prefix.pch";
INFOPLIST_FILE = "JNJProgressButton-Sample/JNJProgressButton-Sample-Info.plist";
@@ -326,6 +332,7 @@
A464A231177E9DB600BCE741 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JNJProgressButton-Sample/JNJProgressButton-Sample-Prefix.pch";
INFOPLIST_FILE = "JNJProgressButton-Sample/JNJProgressButton-Sample-Info.plist";
diff --git a/JNJProgressButton-Sample/JNJSampleViewController.m b/JNJProgressButton-Sample/JNJSampleViewController.m
index 790f1a8..3ab617f 100644
--- a/JNJProgressButton-Sample/JNJSampleViewController.m
+++ b/JNJProgressButton-Sample/JNJSampleViewController.m
@@ -127,19 +127,24 @@ - (IBAction)showActionSheet:(id)sender
- (void)startProgressWithButton:(JNJProgressButton *)button
{
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
- [NSThread sleepForTimeInterval:3];
- NSInteger index = 0;
- while (index <= 100) {
- [NSThread sleepForTimeInterval:0.04];
- dispatch_async(dispatch_get_main_queue(), ^{
- button.progress = (index / 100.0f);
- });
- index++;
-
- if (!button.progressing) return;
- }
- });
+ [button endProgressWithState:JNJProgressButtonStateUnstarted];
+//
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+// [button endProgressWithState:JNJProgressButtonStateFinished];
+// });
+// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
+// [NSThread sleepForTimeInterval:3];
+// NSInteger index = 0;
+// while (index <= 100) {
+// [NSThread sleepForTimeInterval:0.04];
+// dispatch_async(dispatch_get_main_queue(), ^{
+// button.progress = (index / 100.0f);
+// });
+// index++;
+//
+// if (!button.progressing) return;
+// }
+// });
}
@end
diff --git a/JNJProgressButton-Sample/JNJSampleViewController.xib b/JNJProgressButton-Sample/JNJSampleViewController.xib
index 54e1950..b61f611 100644
--- a/JNJProgressButton-Sample/JNJSampleViewController.xib
+++ b/JNJProgressButton-Sample/JNJSampleViewController.xib
@@ -1,963 +1,96 @@
-
-
-
- 1552
- 12E55
- 4457.9
- 1187.39
- 626.00
-
-
- IBNSLayoutConstraint
- IBProxyObject
- IBUIButton
- IBUIView
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
-
-
-
-
-
-
- view
-
-
-
- 3
-
-
-
- progressButton
-
-
-
- 22
-
-
-
- progressButton2
-
-
-
- 193
-
-
-
- progressButton3
-
-
-
- 194
-
-
-
- progressButton4
-
-
-
- 224
-
-
-
- resetProgressButton:
-
-
- 7
-
- 147
-
-
-
- showActionSheet:
-
-
- 7
-
- 148
-
-
-
-
-
- 0
-
-
-
-
-
- 1
-
-
-
-
- 6
- 0
-
- 6
- 1
-
- 0.0
-
- 1000
-
- 6
- 24
- 2
- N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1
-
- 28
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
- 7
- 0
-
- 0
- 1
-
- 64
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
-
-
- 173
-
-
-
-
- 174
-
-
-
-
- 177
-
-
-
-
- 178
-
-
-
-
- 184
-
-
-
-
- 7
- 0
-
- 0
- 1
-
- 64
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
- 8
- 0
-
- 0
- 1
-
- 28
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
-
-
- 185
-
-
-
-
- 186
-
-
-
-
- 198
-
-
-
-
- 199
-
-
-
-
- 8
- 0
-
- 0
- 1
-
- 28
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
- 7
- 0
-
- 0
- 1
-
- 64
-
- 1000
-
- 9
- 40
- 1
- NO
-
-
-
-
-
- 200
-
-
-
-
- 201
-
-
-
-
- 213
-
-
-
-
- 214
-
-
-
-
- 215
-
-
-
-
- 218
-
-
-
-
- 220
-
-
-
-
- 221
-
-
-
-
- 222
-
-
-
-
- 223
-
-
-
-
-
-
- JNJSampleViewController
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- UIResponder
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- JNJProgressButton
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- JNJProgressButton
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- JNJProgressButton
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- JNJProgressButton
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
-
-
-
-
-
-
-
- 224
-
-
-
-
- JNJProgressButton
- UIView
-
- IBProjectSource
- ./Classes/JNJProgressButton.h
-
-
-
- JNJSampleViewController
- UIViewController
-
- id
- id
-
-
-
- resetProgressButton:
- id
-
-
- showActionSheet:
- id
-
-
-
- JNJProgressButton
- JNJProgressButton
- JNJProgressButton
- JNJProgressButton
-
-
-
- progressButton
- JNJProgressButton
-
-
- progressButton2
- JNJProgressButton
-
-
- progressButton3
- JNJProgressButton
-
-
- progressButton4
- JNJProgressButton
-
-
-
- IBProjectSource
- ./Classes/JNJSampleViewController.h
-
-
-
- NSLayoutConstraint
- NSObject
-
- IBProjectSource
- ./Classes/NSLayoutConstraint.h
-
-
-
-
- 0
- IBCocoaTouchFramework
-
- com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
-
-
-
- com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
-
-
- YES
- 3
- YES
- 3682.9
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/JNJProgressButton/JNJProgressButton.h b/JNJProgressButton/JNJProgressButton.h
index aeb3ddc..3d4297a 100644
--- a/JNJProgressButton/JNJProgressButton.h
+++ b/JNJProgressButton/JNJProgressButton.h
@@ -24,6 +24,12 @@
#import
+typedef NS_ENUM(NSUInteger, JNJProgressButtonState) {
+ JNJProgressButtonStateUnstarted,
+ JNJProgressButtonStateProgressing,
+ JNJProgressButtonStateFinished
+};
+
@class JNJProgressButton;
typedef void(^JNJProgressButtonBlockAction)(JNJProgressButton *button);
@@ -84,6 +90,11 @@ typedef void(^JNJProgressButtonBlockAction)(JNJProgressButton *button);
*/
@property (nonatomic, copy) JNJProgressButtonBlockAction progressDidCancelBlock;
+/** Diametr */
+@property (assign, nonatomic) CGFloat kJNJProgressCircleDiameter;
+
+- (void)endProgressWithState:(JNJProgressButtonState)state;
+
/** Set the current progress of the button
@param progress The float value of the progress from 0.0 to 1.0. Values outside of this are pinned.
@param animated Boolean flag to specify if this change should be animated
diff --git a/JNJProgressButton/JNJProgressButton.m b/JNJProgressButton/JNJProgressButton.m
index a860d06..c3a60b6 100644
--- a/JNJProgressButton/JNJProgressButton.m
+++ b/JNJProgressButton/JNJProgressButton.m
@@ -25,16 +25,9 @@ this software and associated documentation files (the "Software"), to deal in
#import "JNJProgressButton.h"
#import
-static CGFloat const kJNJProgressCircleDiameter = 20.0f;
static CGFloat const kJNJProgressCircleShadowRadius = 5.0f;
static CGFloat const kJNJProgressStopWidth = 5.0f;
-typedef NS_ENUM(NSUInteger, JNJProgressButtonState) {
- JNJProgressButtonStateUnstarted,
- JNJProgressButtonStateProgressing,
- JNJProgressButtonStateFinished
-};
-
@interface JNJProgressButton ()
@property (nonatomic, assign) JNJProgressButtonState state;
@@ -69,6 +62,9 @@ - (id)initWithFrame:(CGRect)frame
- (void)commonInit
{
+ if (!self.kJNJProgressCircleDiameter) {
+ self.kJNJProgressCircleDiameter = 20.0f;
+ }
self.needsProgress = YES;
self.state = JNJProgressButtonStateUnstarted;
[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(progressButtonWasTapped:)]];
@@ -327,10 +323,10 @@ - (UIImage *)imageForState:(JNJProgressButtonState)state
- (CGRect)rectForProgressCircle
{
return (CGRect) {
- CGRectGetMidX(self.bounds) - kJNJProgressCircleDiameter / 2.0f,
- CGRectGetMidY(self.bounds) - kJNJProgressCircleDiameter / 2.0f,
- kJNJProgressCircleDiameter,
- kJNJProgressCircleDiameter
+ CGRectGetMidX(self.bounds) - self.kJNJProgressCircleDiameter / 2.0f,
+ CGRectGetMidY(self.bounds) - self.kJNJProgressCircleDiameter / 2.0f,
+ self.kJNJProgressCircleDiameter,
+ self.kJNJProgressCircleDiameter
};
}