Skip to content

Fixed progressBarTo Artifact Issue #17

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions Source/BarGraph/GKBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ - (void)setPercentage:(CGFloat)percentage {
_percentage = percentage;
}

- (void)_progressBarTo:(CGFloat)value {
CGFloat converted = (value / 100);
- (void)_progressBarTo:(CGFloat)value
{
CGFloat converted = (value < 0.5f ? 0.0f : floorf(value * 2) / 2 / 100);
UIBezierPath *path = [self _bezierPathWith:converted];

CAShapeLayer *layer = [self _layerWithPath:path];
Expand All @@ -114,10 +114,12 @@ - (void)_progressBarTo:(CGFloat)value {
- (UIBezierPath *)_bezierPathWith:(CGFloat)value {
UIBezierPath *path = [UIBezierPath bezierPath];
CGFloat startX = (self.frame.size.width / 2);
CGFloat startY = (self.frame.size.height * (1 - (_percentage / 100)));
CGFloat endY = (self.frame.size.height * (1 - value));
CGFloat startY0 = (self.frame.size.height * (1 - (_percentage / 100)));
CGFloat startY = startY0 < 0.5f ? 0.0f : floorf(startY0 * 2) / 2;
CGFloat endY0 = (self.frame.size.height * (1 - value));
CGFloat endY = endY0 < 0.5f ? 0.0f : floorf(endY0 * 2) / 2;
[path moveToPoint:CGPointMake(startX, startY)];
[path addLineToPoint:CGPointMake(startX, endY)];
[path addLineToPoint:CGPointMake(startX, endY)];
return path;
}

Expand Down