Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
fix issue#4
Browse files Browse the repository at this point in the history
  • Loading branch information
Cokile committed Jan 14, 2017
1 parent c51c52c commit 73831e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CCActivityHUD.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]' }
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'
Expand Down
36 changes: 10 additions & 26 deletions CCActivityHUD/CCActivityHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -302,6 +284,8 @@ - (instancetype)init {
self.layer.cornerRadius = 5.0;

self.isTheOnlyActiveView = YES;

self.indicatorColor = [UIColor whiteColor];

self.appearAnimationType = CCActivityHUDAppearAnimationTypeFadeIn;
self.disappearAnimationType = CCActivityHUDDisappearAnimationTypeFadeOut;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 73831e3

Please sign in to comment.