From 73831e3faa985cbdc90ad0986e343bc518527acc Mon Sep 17 00:00:00 2001 From: Kelvin Date: Sat, 14 Jan 2017 14:02:27 +0800 Subject: [PATCH] fix issue#4 --- CCActivityHUD.podspec | 4 ++-- CCActivityHUD/CCActivityHUD.m | 36 ++++++++++------------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/CCActivityHUD.podspec b/CCActivityHUD.podspec index f3d02ad..2cf2283 100644 --- a/CCActivityHUD.podspec +++ b/CCActivityHUD.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = 'CCActivityHUD' spec.platform = :ios - spec.version = '2.1.6' + spec.version = '2.1.7' spec.license = { :type => 'MIT' } spec.homepage = 'https://github.com/Cokile/CCActivityHUD' spec.authors = { 'Cokile' => 'kelvintgx@gmail.com' } spec.summary = 'A simple replacement for UIActivityIndicatorView' - spec.source = {:git => 'https://github.com/Cokile/CCActivityHUD.git', :tag => 'v2.1.6'} + spec.source = {:git => 'https://github.com/Cokile/CCActivityHUD.git', :tag => 'v2.1.7'} spec.source_files = 'CCActivityHUD/*.{h,m}' spec.resources = 'CCActivityHUD/*.png' spec.frameworks = 'ImageIO' diff --git a/CCActivityHUD/CCActivityHUD.m b/CCActivityHUD/CCActivityHUD.m index 05c2e17..9ef8a05 100644 --- a/CCActivityHUD/CCActivityHUD.m +++ b/CCActivityHUD/CCActivityHUD.m @@ -13,7 +13,6 @@ @interface CCActivityHUD () @property (strong, nonatomic) CAShapeLayer *indicatorCAShapeLayer; @property (strong, nonatomic) UIImageView *imageView; -@property (strong, nonatomic) UIColor *updatedColor; @property CCActivityHUDIndicatorType currentTpye; @property BOOL useProvidedIndicator; @property BOOL useProgress; @@ -47,10 +46,6 @@ - (void)setCornerRadius:(CGFloat)cornerRadius { } } -- (void)setIndicatorColor:(UIColor *)indicatorColor { - self.updatedColor = indicatorColor; -} - - (void)setProgress:(CGFloat)progress { if (self.indicatorCAShapeLayer && self.useProgress) { if (progress >= 1) { @@ -79,18 +74,7 @@ - (void)showWithType:(CCActivityHUDIndicatorType)type { self.currentTpye = type; self.useProvidedIndicator = YES; self.useProgress = NO; - - // change the indicator color if user do not use the default color. - // You will confused that why not change the indicator color within the relevant setter, - // If so, I need to initialize self.indicatorCAShapeLayer in the init method, - // However, this will cause a problem (or bug) that the animation not works, - // Meanwhile, when user use GIF instead of provided animation types, - // the init method will create two useless instances, - // since showing GIF not rely on self.indicatorCAShapeLayer - if (self.indicatorCAShapeLayer && self.updatedColor) { - self.indicatorCAShapeLayer.strokeColor = self.updatedColor.CGColor; - } - + [self communalShowTask]; } } @@ -198,9 +182,7 @@ - (void)showWithProgress { self.indicatorCAShapeLayer.path = [self arcPathWithStartAngle:-M_PI/2 span:2*M_PI]; self.indicatorCAShapeLayer.strokeEnd = 0.0; - if (self.indicatorCAShapeLayer && self.updatedColor) { - self.indicatorCAShapeLayer.strokeColor = self.updatedColor.CGColor; - } + self.indicatorCAShapeLayer.strokeColor = self.indicatorColor.CGColor; self.progress = 0.0; self.useProvidedIndicator = NO; @@ -302,6 +284,8 @@ - (instancetype)init { self.layer.cornerRadius = 5.0; self.isTheOnlyActiveView = YES; + + self.indicatorColor = [UIColor whiteColor]; self.appearAnimationType = CCActivityHUDAppearAnimationTypeFadeIn; self.disappearAnimationType = CCActivityHUDDisappearAnimationTypeFadeOut; @@ -368,7 +352,7 @@ - (void)initializeScalingDots { CGFloat length = ViewFrameWidth*18/200; self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.backgroundColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.backgroundColor = self.indicatorColor.CGColor; self.indicatorCAShapeLayer.frame = CGRectMake(0, 0, length, length); self.indicatorCAShapeLayer.position = CGPointMake(ViewFrameWidth/2, ViewFrameHeight/5); self.indicatorCAShapeLayer.cornerRadius = length/2; @@ -386,7 +370,7 @@ - (void)initializeLeadingDots { CGFloat length = ViewFrameWidth*25/200; self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.backgroundColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.backgroundColor = self.indicatorColor.CGColor; self.indicatorCAShapeLayer.frame = CGRectMake(0, 0, length, length); self.indicatorCAShapeLayer.position = CGPointMake(ViewFrameWidth/2, ViewFrameHeight/5); self.indicatorCAShapeLayer.cornerRadius = length/2; @@ -401,7 +385,7 @@ - (void)initializeLeadingDots { - (void)initializeMinorArc { self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.strokeColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.strokeColor = self.indicatorColor.CGColor; self.indicatorCAShapeLayer.fillColor = [UIColor clearColor].CGColor; self.indicatorCAShapeLayer.lineWidth = ViewFrameWidth/24; @@ -429,7 +413,7 @@ - (void)initializeSpringBall { CGFloat length = ViewFrameWidth*38/200; self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.backgroundColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.backgroundColor = self.indicatorColor.CGColor; self.indicatorCAShapeLayer.frame = CGRectMake(0, 0, length, length); self.indicatorCAShapeLayer.position = CGPointMake(ViewFrameWidth/2, ViewFrameHeight/5); self.indicatorCAShapeLayer.cornerRadius = length/2; @@ -439,7 +423,7 @@ - (void)initializeScalingBars { self.replicatorLayer.instanceCount = 5; self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.backgroundColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.backgroundColor = self.indicatorColor.CGColor; CGFloat padding = 10; self.indicatorCAShapeLayer.frame = CGRectMake(padding, ViewFrameHeight/4,(ViewFrameWidth-padding*2)*2/3/self.replicatorLayer.instanceCount, ViewFrameHeight/2); self.indicatorCAShapeLayer.cornerRadius = FrameWidthFor(self.indicatorCAShapeLayer)/2; @@ -452,7 +436,7 @@ - (void)initializeTriangleCircle { CGFloat length = ViewFrameWidth*25/200; self.indicatorCAShapeLayer = [[CAShapeLayer alloc] init]; - self.indicatorCAShapeLayer.backgroundColor = [UIColor whiteColor].CGColor; + self.indicatorCAShapeLayer.backgroundColor = self.indicatorColor.CGColor; self.indicatorCAShapeLayer.frame = CGRectMake(0, 0, length, length); self.indicatorCAShapeLayer.position = CGPointMake(ViewFrameWidth/2, ViewFrameHeight/5); self.indicatorCAShapeLayer.cornerRadius = length/2;