Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix progresscolor #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ASProgressPopUpView.podspec
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion ASProgressPopUpView/ASProgressPopUpView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 24 additions & 11 deletions ASProgressPopUpView/ASProgressPopUpView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "ASPopUpView.h"
#import "ASProgressPopUpView.h"
#import <QuartzCore/QuartzCore.h>

@interface ASProgressPopUpView() <ASPopUpViewDelegate>
@property (strong, nonatomic) NSNumberFormatter *numberFormatter;
Expand Down Expand Up @@ -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)];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not had time to check, but I don't think it's necessary to manually calculate the gradient positions. If nil is passed as the arg to positions in the gradient layer, the color positions along the gradient are automatically calculated. (unless things have changed recently?)

Copy link
Author

@hons82 hons82 Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I had something else wrong here... however I got just a black background

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm… that's weird, sorry about that.

In the example project the gradient animation works without having to manually calculate the gradient stop positions. Are you doing something slightly different to the example project, which could potentially result in the black background instead of a gradient? Perhaps there's something unclear in the API that could be the cause?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give it another try with a fresh checkout... I'll let u know tomorrow

[self setPopUpViewAnimatedColors:colors withPositions:positions];
}
}

// if 2 or more colors are present, set animated colors
Expand Down Expand Up @@ -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
{
Expand Down