From 0ea7e92e991da48d08e85957762e4ca0cf4903d8 Mon Sep 17 00:00:00 2001 From: Hannes Tribus Date: Tue, 22 Nov 2016 15:20:15 +0100 Subject: [PATCH] Fix progresscolor gradient and solid --- ASProgressPopUpView.podspec | 5 ++-- ASProgressPopUpView/ASProgressPopUpView.h | 2 +- ASProgressPopUpView/ASProgressPopUpView.m | 35 ++++++++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ASProgressPopUpView.podspec b/ASProgressPopUpView.podspec index d85a62e..f16b875 100644 --- a/ASProgressPopUpView.podspec +++ b/ASProgressPopUpView.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "ASProgressPopUpView" - s.version = "0.9" + s.version = "0.9.1" s.summary = "A progress view showing percentage complete in an animated popUpView" s.description = <<-DESC * Customize: font, font color, background color, corner radius @@ -12,9 +12,10 @@ Pod::Spec.new do |s| s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "Al Skipp" => "al_skipp@fastmail.fm" } s.social_media_url = 'https://twitter.com/al_skipp' - + s.platform = :ios, '8.0' s.source = { :git => "https://github.com/alskipp/ASProgressPopUpView.git", :tag => "0.9" } s.source_files = 'ASProgressPopUpView' s.requires_arc = true + s.frameworks = 'QuartzCore', 'CoreGraphics' end diff --git a/ASProgressPopUpView/ASProgressPopUpView.h b/ASProgressPopUpView/ASProgressPopUpView.h index 4d16712..fd5997a 100644 --- a/ASProgressPopUpView/ASProgressPopUpView.h +++ b/ASProgressPopUpView/ASProgressPopUpView.h @@ -16,7 +16,7 @@ - (void)hidePopUpViewAnimated:(BOOL)animated; @property(nonatomic) float progress; // 0.0 .. 1.0, default is 0.0. values outside are pinned. -//@property(strong, nonatomic) UIColor* progressTintColor; +@property(strong, nonatomic) UIColor* progressTintColor; @property(strong, nonatomic) UIColor* trackTintColor; - (void)setProgress:(float)progress animated:(BOOL)animated; diff --git a/ASProgressPopUpView/ASProgressPopUpView.m b/ASProgressPopUpView/ASProgressPopUpView.m index e4dde4f..d5d85ae 100644 --- a/ASProgressPopUpView/ASProgressPopUpView.m +++ b/ASProgressPopUpView/ASProgressPopUpView.m @@ -8,6 +8,7 @@ #import "ASPopUpView.h" #import "ASProgressPopUpView.h" +#import @interface ASProgressPopUpView() @property (strong, nonatomic) NSNumberFormatter *numberFormatter; @@ -99,12 +100,24 @@ - (void)setPopUpViewColor:(UIColor *)color _popUpViewColor = color; _popUpViewAnimatedColors = nil; // animated colors should be discarded [self.popUpView setColor:color]; - [self setGradientColors:@[color, color] withPositions:nil]; + [self setGradientColors:@[color, color] withPositions:@[@(0.0), @(1.0)]]; } - (void)setPopUpViewAnimatedColors:(NSArray *)colors { - [self setPopUpViewAnimatedColors:colors withPositions:nil]; + if ([colors count]==0) { + return; + } else if ([colors count]==1) { + [self setPopUpViewAnimatedColors:@[colors[0], colors[0]] withPositions:@[@(0.0), @(1.0)]]; + } else { + CGFloat spacer = 1.0 / ([colors count]-1); + NSMutableArray *positions = [[NSMutableArray alloc] initWithCapacity:[colors count]]; + for (NSInteger i = 0; i < [colors count]; i++) { + [positions addObject:@(i * spacer)]; + } + [positions addObject:@(1.0)]; + [self setPopUpViewAnimatedColors:colors withPositions:positions]; + } } // if 2 or more colors are present, set animated colors @@ -277,15 +290,15 @@ - (void)didMoveToWindow } } -//- (void)setProgressTintColor:(UIColor *)color -//{ -// self.progressLayer.backgroundColor = color.CGColor; -//} -// -//- (UIColor *)progressTintColor -//{ -// return [UIColor colorWithCGColor:self.progressLayer.backgroundColor]; -//} +- (void)setProgressTintColor:(UIColor *)color +{ + _progressLayer.backgroundColor = color.CGColor; +} + +- (UIColor *)progressTintColor +{ + return [UIColor colorWithCGColor:_progressLayer.backgroundColor]; +} - (void)setProgress:(float)progress {