17 Commits

Author SHA1 Message Date
Brandon McQuilkin 2ca59b59b3 Forgot to change source tag. 2016-11-10 07:54:56 -05:00
Brandon McQuilkin 5a13d866b8 Updated pod spec version after merging multiple pull requests. 2016-11-10 07:53:41 -05:00
Brandon McQuilkin 5927f8faaa Merge pull request #113 from ilyavelilyaev/master
Added ability to set custom background color to UINavigationBar progress bar.
2016-11-10 07:50:16 -05:00
Brandon McQuilkin e6b7550d5e Merge pull request #110 from algrid/fix-67
Update _backgroundLayer.lineWidth on borderWidth change in striped bar
2016-11-10 07:44:41 -05:00
Brandon McQuilkin d46c8a6279 Merge pull request #109 from algrid/fix-grayscale
M13ProgressViewImage - fix createImageForCurrentProgress (types and g…
2016-11-10 07:44:05 -05:00
Brandon McQuilkin cee320a57d Merge pull request #108 from charlymr/master
Fixed #105
2016-11-10 07:43:28 -05:00
Brandon McQuilkin 63b422fac8 Merge pull request #106 from zanesc/master
Fixed M13ProgressHUD not updating own progress value when setProgre…
2016-11-10 07:42:56 -05:00
Ilya Velilyaev a2f4e8448d Fix unability to set clear background color 2016-11-03 14:01:11 +03:00
Ilya Velilyaev 8d97ac8b71 Added example 2016-11-03 13:59:18 +03:00
Ilya Velilyaev 8971d7493a fixed background color not setting 2016-11-03 13:48:52 +03:00
Ilya Velilyaev 93772f7a65 added background color to navigation bar progress view 2016-11-03 13:40:41 +03:00
Alexei Gridnev 148a116c73 Update _backgroundLayer.lineWidth on borderWidth change in striped bar 2016-10-27 02:07:41 +03:00
Alexei Gridnev 5c64775358 M13ProgressViewImage - fix createImageForCurrentProgress (types and grayscale calculation) 2016-10-26 01:20:23 +03:00
MARTIN Denis bb382e58bc Fixed #105
This should fixed the issue with the secondary color.
2016-10-19 10:56:44 +02:00
Zane Campbell 25348b780c - fixed M13ProgressHUD not updating own progress value when setProgress called 2016-10-07 05:02:14 -04:00
Brandon McQuilkin c89079d627 Fixed invalid context error: Issue #35 2016-08-10 08:21:55 -04:00
Brandon McQuilkin 31fec485e0 Fixed more Xcode warnings. 2016-08-10 08:18:27 -04:00
14 changed files with 514 additions and 315 deletions
+48 -41
View File
@@ -286,6 +286,7 @@
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated
{
[_progressView setProgress:progress animated:animated];
self.progress = progress;
}
- (void)performAction:(M13ProgressViewAction)action animated:(BOOL)animated
@@ -301,7 +302,7 @@
[self setNeedsDisplay];
onScreen = YES;
//Animate the HUD on screen
CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.duration = _animationDuration;
@@ -329,7 +330,7 @@
{
positionAnimation.fromValue = [NSValue valueWithCGPoint:_animationPoint];
}
positionAnimation.toValue = [NSValue valueWithCGPoint:backgroundView.layer.position];
positionAnimation.removedOnCompletion = YES;
@@ -350,7 +351,7 @@
fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0];
fadeAnimation.removedOnCompletion = YES;
[self.layer addAnimation:fadeAnimation forKey:@"fadeAnimation"];
self.layer.opacity = 0.0;
@@ -358,7 +359,7 @@
scaleAnimation.fromValue = [NSNumber numberWithFloat:1.0];
scaleAnimation.toValue = [NSNumber numberWithFloat:0.0];
scaleAnimation.removedOnCompletion = YES;
CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
if (_animationCentered)
@@ -407,7 +408,7 @@
- (void)deviceOrientationDidChange:(NSNotification *)notification {
UIDeviceOrientation deviceOrientation = [notification.object orientation];
if (_shouldAutorotate && UIDeviceOrientationIsValidInterfaceOrientation(deviceOrientation)) {
if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown) {
@@ -556,7 +557,7 @@
}
backgroundRect.origin.x = (self.bounds.size.width / 2.0) - (backgroundRect.size.width / 2.0);
backgroundRect.origin.y = (self.bounds.size.height / 2.0) - (_minimumSize.height / 2.0);
backgroundRect.origin.y = (self.bounds.size.height / 2.0) - (_minimumSize.height / 2.0);
//There is no status label text, center the progress view
progressRect.origin.x = (backgroundRect.size.width / 2.0) - (progressRect.size.width / 2.0);
@@ -696,6 +697,11 @@
//Create the gradient as an image, and then set it as the color of the mask view.
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();
if (!context) {
return;
}
//Create the gradient
size_t locationsCount = 2;
CGFloat locations[2] = {0.0f, 1.0f};
@@ -713,6 +719,7 @@
UIGraphicsEndImageContext();
//Set the background
maskView.backgroundColor = [UIColor colorWithPatternImage:image];
} else if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
// do nothing; we don't want to take a snapshot of the background for blurring now, no idea what the background is
}
@@ -720,45 +727,45 @@
- (void)redrawBlurs
{
if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
//Get the snapshot of the mask
__block UIImage *image = [self snapshotForBlurredBackgroundInView:maskView];
if (image != nil) {
//Apply the filters to blur the image
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
image = [image applyLightEffect];
dispatch_async(dispatch_get_main_queue(), ^{
// Fade on content's change, if there was already an image.
CATransition *transition = [CATransition new];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self->maskView.layer addAnimation:transition forKey:nil];
self->maskView.backgroundColor = [UIColor colorWithPatternImage:image];
});
if (_maskType == M13ProgressHUDMaskTypeIOS7Blur) {
//Get the snapshot of the mask
__block UIImage *image = [self snapshotForBlurredBackgroundInView:maskView];
if (image != nil) {
//Apply the filters to blur the image
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
image = [image applyLightEffect];
dispatch_async(dispatch_get_main_queue(), ^{
// Fade on content's change, if there was already an image.
CATransition *transition = [CATransition new];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self->maskView.layer addAnimation:transition forKey:nil];
self->maskView.backgroundColor = [UIColor colorWithPatternImage:image];
});
}
});
}
if (_applyBlurToBackground) {
//Get the snapshot of the mask
__block UIImage *image = [self snapshotForBlurredBackgroundInView:backgroundView];
if (image != nil) {
//Apply the filters to blur the image
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//image = [image applyLightEffect];
image = [image applyLightEffect];
dispatch_async(dispatch_get_main_queue(), ^{
// Fade on content's change, if there was already an image.
CATransition *transition = [CATransition new];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self->backgroundView.layer addAnimation:transition forKey:nil];
self->backgroundView.backgroundColor = [UIColor colorWithPatternImage:image];
});
}
if (_applyBlurToBackground) {
//Get the snapshot of the mask
__block UIImage *image = [self snapshotForBlurredBackgroundInView:backgroundView];
if (image != nil) {
//Apply the filters to blur the image
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//image = [image applyLightEffect];
image = [image applyLightEffect];
dispatch_async(dispatch_get_main_queue(), ^{
// Fade on content's change, if there was already an image.
CATransition *transition = [CATransition new];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self->backgroundView.layer addAnimation:transition forKey:nil];
self->backgroundView.backgroundColor = [UIColor colorWithPatternImage:image];
});
}
});
}
}
}
- (UIImage *)snapshotForBlurredBackgroundInView:(UIView *)view
@@ -50,5 +50,11 @@
@param secondaryColor The color to set.
*/
- (void)setSecondaryColor:(UIColor *)secondaryColor;
/**
The background color of the progress bar, if nil, the background color will be the clearColor.
@param background The color to set.
*/
- (void)setBackgroundColor:(UIColor *)backgroundColor;
@end
@@ -20,6 +20,8 @@ static char indeterminateLayerKey;
static char isShowingProgressKey;
static char primaryColorKey;
static char secondaryColorKey;
static char backgroundColorKey;
static char backgroundViewKey;
@implementation UINavigationController (M13ProgressViewBar)
@@ -91,8 +93,8 @@ static char secondaryColorKey;
- (void)finishProgress
{
UIView *progressView = [self getProgressView];
if (progressView) {
UIView *backgroundView = [self getBackgroundView];
if (progressView && backgroundView) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.1 animations:^{
CGRect progressFrame = progressView.frame;
@@ -101,8 +103,11 @@ static char secondaryColorKey;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.5 animations:^{
progressView.alpha = 0;
backgroundView.alpha = 0;
} completion:^(BOOL finished) {
[progressView removeFromSuperview];
[backgroundView removeFromSuperview];
backgroundView.alpha = 1;
progressView.alpha = 1;
[self setTitle:nil];
[self setIsShowingProgressBar:NO];
@@ -115,14 +120,18 @@ static char secondaryColorKey;
- (void)cancelProgress
{
UIView *progressView = [self getProgressView];
if (progressView) {
UIView *backgroundView = [self getBackgroundView];
if (progressView && backgroundView) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.5 animations:^{
progressView.alpha = 0;
backgroundView.alpha = 0;
} completion:^(BOOL finished) {
[progressView removeFromSuperview];
[backgroundView removeFromSuperview];
progressView.alpha = 1;
backgroundView.alpha = 1;
[self setTitle:nil];
[self setIsShowingProgressBar:NO];
}];
@@ -154,9 +163,11 @@ static char secondaryColorKey;
- (void)showProgress
{
UIView *progressView = [self getProgressView];
UIView *backgroundView = [self getBackgroundView];
[UIView animateWithDuration:.1 animations:^{
progressView.alpha = 1;
backgroundView.alpha = 1;
}];
[self setIsShowingProgressBar:YES];
@@ -174,14 +185,31 @@ static char secondaryColorKey;
if(!progressView)
{
progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 2.5)];
progressView.backgroundColor = self.navigationBar.tintColor;
if ([self getPrimaryColor]) {
progressView.backgroundColor = [self getPrimaryColor];
}
progressView.clipsToBounds = YES;
[self setProgressView:progressView];
}
if ([self getPrimaryColor]) {
progressView.backgroundColor = [self getPrimaryColor];
} else {
progressView.backgroundColor = self.navigationBar.tintColor;
}
//Create background view if it doesn't exist
UIView *backgroundView = [self getBackgroundView];
if (!backgroundView)
{
backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 2.5)];
backgroundView.clipsToBounds = YES;
[self setBackgroundView:backgroundView];
}
if ([self getBackgroundColor]) {
backgroundView.backgroundColor = [self getBackgroundColor];
} else {
backgroundView.backgroundColor = [UIColor clearColor];
}
//Calculate the frame of the navigation bar, based off the orientation.
UIView *topView = self.topViewController.view;
CGSize screenSize;
@@ -209,6 +237,7 @@ static char secondaryColorKey;
//Check if the progress view is in its superview and if we are showing the bar.
if (progressView.superview == nil && [self isShowingProgressBar]) {
[self.navigationBar addSubview:backgroundView];
[self.navigationBar addSubview:progressView];
}
@@ -222,7 +251,7 @@ static char secondaryColorKey;
//Calculate the width of the progress view
progressView.frame = CGRectMake(0, height - 2.5, width, 2.5);
}
backgroundView.frame = CGRectMake(0, height - 2.5, width, 2.5);
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
@@ -437,6 +466,17 @@ static char secondaryColorKey;
return objc_getAssociatedObject(self, &progressViewKey);
}
- (void)setBackgroundView:(UIView *)view
{
objc_setAssociatedObject(self, &backgroundViewKey, view, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (UIView *)getBackgroundView
{
return objc_getAssociatedObject(self, &backgroundViewKey);
}
- (void)setIndeterminate:(BOOL)indeterminate
{
objc_setAssociatedObject(self, &indeterminateKey, [NSNumber numberWithBool:indeterminate], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
@@ -488,4 +528,15 @@ static char secondaryColorKey;
return objc_getAssociatedObject(self, &secondaryColorKey);
}
- (void)setBackgroundColor:(UIColor *)backgroundColor
{
objc_setAssociatedObject(self, &backgroundColorKey, backgroundColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self setIndeterminate:[self getIndeterminate]];
}
- (UIColor *)getBackgroundColor
{
return objc_getAssociatedObject(self, &backgroundColorKey);
}
@end
+9 -9
View File
@@ -187,10 +187,10 @@
- (UIImage *)createImageForCurrentProgress
{
const int ALPHA = 0;
const int RED = 1;
const int RED = 3;
const int GREEN = 2;
const int BLUE = 3;
const int BLUE = 1;
//Create image rectangle with current image width/height
CGRect imageRect = CGRectMake(0, 0, _progressImage.size.width * _progressImage.scale, _progressImage.size.height * _progressImage.scale);
@@ -218,23 +218,23 @@
int yTo = height;
if (_progressDirection == M13ProgressViewImageProgressDirectionBottomToTop) {
yTo = height * (int)(1 - self.progress);
yTo = (int)(height * (1 - self.progress));
} else if (_progressDirection == M13ProgressViewImageProgressDirectionTopToBottom) {
yFrom = height * (int)self.progress;
yFrom = (int)(height * self.progress);
} else if (_progressDirection == M13ProgressViewImageProgressDirectionLeftToRight) {
xFrom = width * (int)self.progress;
xFrom = (int)(width * self.progress);
} else if (_progressDirection == M13ProgressViewImageProgressDirectionRightToLeft) {
xTo = width * (int)(1 - self.progress);
xTo = (int)(width * (1 - self.progress));
}
for (int x = xFrom; x < xTo; x++) {
for (int y = yFrom; y < yTo; y++) {
//Get the pixel
uint32_t *rgbaPixel = (uint32_t *) &pixels[y * width + x];
uint8_t *rgbaPixel = (uint8_t *) &pixels[y * width + x];
//Convert
if (_drawGreyscaleBackground) {
//Convert to grayscale using luma coding: http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
uint32_t gray = (uint32_t)(0.3 * rgbaPixel[RED] + 0.59 * rgbaPixel[GREEN] + 0.11 * rgbaPixel[BLUE]);
uint8_t gray = (uint8_t)(0.3 * rgbaPixel[RED] + 0.59 * rgbaPixel[GREEN] + 0.11 * rgbaPixel[BLUE]);
// set the pixels to gray
rgbaPixel[RED] = gray;
rgbaPixel[GREEN] = gray;
+16 -16
View File
@@ -181,18 +181,18 @@
- (void)animateProgress:(CADisplayLink *)displayLink
{
dispatch_async(dispatch_get_main_queue(), ^{
CGFloat dt = (displayLink.timestamp - _animationStartTime) / self.animationDuration;
CGFloat dt = (displayLink.timestamp - self.animationStartTime) / self.animationDuration;
if (dt >= 1.0) {
//Order is important! Otherwise concurrency will cause errors, because setProgress: will detect an animation in progress and try to stop it by itself. Once over one, set to actual progress amount. Animation is over.
[self.displayLink invalidate];
self.displayLink = nil;
[super setProgress:_animationToValue animated:NO];
[super setProgress:self.animationToValue animated:NO];
[self setNeedsDisplay];
return;
}
//Set progress
[super setProgress:_animationFromValue + dt * (_animationToValue - _animationFromValue) animated:YES];
[super setProgress:self.animationFromValue + dt * (self.animationToValue - self.animationFromValue) animated:YES];
[self setNeedsDisplay];
});
@@ -230,9 +230,9 @@
[CATransaction begin];
[_iconLayer addAnimation:[self hideAnimation] forKey:kM13ProgressViewPieHideKey];
[CATransaction setCompletionBlock:^{
_currentAction = action;
self.currentAction = action;
[self drawIcon];
[_iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewPieShowKey];
[self.iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewPieShowKey];
}];
[CATransaction commit];
}
@@ -254,9 +254,9 @@
[CATransaction begin];
[_iconLayer addAnimation:[self hideAnimation] forKey:kM13ProgressViewPieHideKey];
[CATransaction setCompletionBlock:^{
_currentAction = action;
self.currentAction = action;
[self drawIcon];
[_iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewPieShowKey];
[self.iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewPieShowKey];
}];
[CATransaction commit];
}
@@ -272,7 +272,7 @@
//Create the rotation animation
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.toValue = [NSNumber numberWithFloat: (float)(M_PI * 2.0)];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;
@@ -290,7 +290,7 @@
[_indeterminateLayer addAnimation:[self hideAnimation] forKey:kM13ProgressViewPieHideKey];
[CATransaction setCompletionBlock:^{
//Remove the rotation animation and reset the background
[_backgroundLayer removeAnimationForKey:@"rotationAnimation"];
[self.backgroundLayer removeAnimationForKey:@"rotationAnimation"];
[self drawBackground];
}];
[CATransaction commit];
@@ -337,7 +337,7 @@
//Update line widths if not overriden
if (!_backgroundRingWidthOverriden) {
_backgroundRingWidth = fmaxf(self.frame.size.width * .025, 1.0);
_backgroundRingWidth = fmaxf((float)self.frame.size.width * .025f, 1.0);
}
//Redraw
@@ -443,8 +443,8 @@
- (void)drawBackground
{
//Create parameters to draw background
float startAngle = - M_PI_2;
float endAngle = startAngle + (2.0 * M_PI);
float startAngle = - (float)M_PI_2;
float endAngle = (float)(startAngle + (2.0 * M_PI));
CGPoint center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.width / 2.0);
CGFloat radius = (self.bounds.size.width - _backgroundRingWidth) / 2.0;
@@ -461,8 +461,8 @@
- (void)drawProgress
{
//Create parameters to draw progress
float startAngle = - M_PI_2;
float endAngle = startAngle + (2.0 * M_PI * self.progress);
float startAngle = - (float)M_PI_2;
float endAngle = (float)(startAngle + (2.0 * M_PI * self.progress));
CGPoint center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.width / 2.0);
CGFloat radius = (self.bounds.size.width - _backgroundRingWidth) / 2.0;
@@ -492,8 +492,8 @@
- (void)drawIndeterminate
{
//Create parameters to draw progress
float startAngle = - M_PI_2;
float endAngle = startAngle + (2.0 * M_PI * .2);
float startAngle = - (float)M_PI_2;
float endAngle = (float)(startAngle + (2.0 * M_PI * .2));
CGPoint center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.width / 2.0);
CGFloat radius = (self.bounds.size.width - _backgroundRingWidth) / 2.0;
+17 -14
View File
@@ -82,7 +82,7 @@
self.backgroundColor = [UIColor clearColor];
//Set defaut sizes
_backgroundRingWidth = fmaxf(self.bounds.size.width * .025, 1.0);
_backgroundRingWidth = fmaxf((float)self.bounds.size.width * .025f, 1.0);
_progressRingWidth = 3 * _backgroundRingWidth;
_progressRingWidthOverriden = NO;
_backgroundRingWidthOverriden = NO;
@@ -250,9 +250,9 @@
[CATransaction begin];
[_iconLayer addAnimation:[self hideAnimation] forKey:kM13ProgressViewRingHideKey];
[CATransaction setCompletionBlock:^{
_currentAction = action;
self.currentAction = action;
[self drawIcon];
[_iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewRingShowKey];
[self.iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewRingShowKey];
}];
[CATransaction commit];
}
@@ -270,9 +270,9 @@
[CATransaction begin];
[_iconLayer addAnimation:[self hideAnimation] forKey:kM13ProgressViewRingHideKey];
[CATransaction setCompletionBlock:^{
_currentAction = action;
self.currentAction = action;
[self drawIcon];
[_iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewRingShowKey];
[self.iconLayer addAnimation:[self showAnimation] forKey:kM13ProgressViewRingShowKey];
}];
[CATransaction commit];
}
@@ -288,7 +288,7 @@
//Create the rotation animation
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.toValue = [NSNumber numberWithFloat: (float)(M_PI * 2.0)];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;
@@ -357,12 +357,15 @@
//Update line widths if not overriden
if (!_backgroundRingWidthOverriden) {
_backgroundRingWidth = fmaxf(self.frame.size.width * .025, 1.0);
_backgroundRingWidth = fmaxf((float)self.frame.size.width * .025f, 1.0);
}
_backgroundLayer.lineWidth = _backgroundRingWidth;
if (!_progressRingWidthOverriden) {
_progressRingWidth = _backgroundRingWidth * 3;
}
_progressLayer.lineWidth = _progressRingWidth;
//Redraw
[self setNeedsDisplay];
}
@@ -462,14 +465,14 @@
- (void)drawBackground
{
//Create parameters to draw background
float startAngle = - M_PI_2;
float endAngle = startAngle + (2.0 * M_PI);
float startAngle = - (float)M_PI_2;
float endAngle = (float)(startAngle + (2.0 * M_PI));
CGPoint center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.width / 2.0);
CGFloat radius = (self.bounds.size.width - _backgroundRingWidth) / 2.0;
//If indeterminate, recalculate the end angle
if (self.indeterminate) {
endAngle = .8 * endAngle;
endAngle = .8f * endAngle;
}
//Draw path
@@ -485,8 +488,8 @@
- (void)drawProgress
{
//Create parameters to draw progress
float startAngle = - M_PI_2;
float endAngle = startAngle + (2.0 * M_PI * self.progress);
float startAngle = - (float)M_PI_2;
float endAngle = (float)(startAngle + (2.0 * M_PI * self.progress));
CGPoint center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.width / 2.0);
CGFloat radius = (self.bounds.size.width - _progressRingWidth) / 2.0;
@@ -500,7 +503,7 @@
[_progressLayer setPath:path.CGPath];
//Update label
_percentageLabel.text = [_percentageFormatter stringFromNumber:[NSNumber numberWithFloat:self.progress]];
_percentageLabel.text = [_percentageFormatter stringFromNumber:[NSNumber numberWithFloat:(float)self.progress]];
}
- (void)drawIcon
@@ -310,13 +310,13 @@
//Create the rotation animation
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.toValue = [NSNumber numberWithFloat: (float)(M_PI * 2.0)];
rotationAnimation.duration = 5 * self.animationDuration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;
CABasicAnimation *rotationAnimationProgress = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimationProgress.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimationProgress.toValue = [NSNumber numberWithFloat: (float)(M_PI * 2.0)];
rotationAnimationProgress.duration = 5 * self.animationDuration;
rotationAnimationProgress.cumulative = YES;
rotationAnimationProgress.repeatCount = HUGE_VALF;
@@ -384,7 +384,7 @@
//Update line widths if not overriden
if (!_progressRingWidthOverriden) {
_progressRingWidth = fmaxf(self.frame.size.width * .25, 1.0);
_progressRingWidth = fmaxf((float)(self.frame.size.width * .25), 1.0);
}
[self updateAngles];
@@ -418,14 +418,14 @@
//Calculate the outer ring angle for the progress segment.*/
outerRingAngle = ((2.0 * M_PI) / (float)_numberOfSegments) - _segmentSeparationAngle;
//Calculate the angle gap for the inner ring
_segmentSeparationInnerAngle = 2.0 * asinf(((self.bounds.size.width / 2.0) * sinf(_segmentSeparationAngle / 2.0)) / ((self.bounds.size.width / 2.0) - _progressRingWidth));
_segmentSeparationInnerAngle = 2.0f * asinf((float)((self.bounds.size.width / 2.0) * sinf((float)_segmentSeparationAngle / 2.0f)) / (((float)self.bounds.size.width / 2.0f) - (float)_progressRingWidth));
//Calculate the inner ring angle for the progress segment.*/
innerRingAngle = ((2.0 * M_PI) / (float)_numberOfSegments) - _segmentSeparationInnerAngle;
}
- (NSInteger)numberOfFullSegments
{
return (NSInteger)floorf(self.progress * _numberOfSegments);
return (NSInteger)floorf((float)(self.progress * _numberOfSegments));
}
#pragma mark Drawing
@@ -585,7 +585,7 @@
CGPathRelease(pathRef);
//Update label
_percentageLabel.text = [_percentageFormatter stringFromNumber:[NSNumber numberWithFloat:self.progress]];
_percentageLabel.text = [_percentageFormatter stringFromNumber:[NSNumber numberWithFloat:(float)self.progress]];
}
- (void)drawIcon
@@ -174,6 +174,7 @@
- (void)setBorderWidth:(CGFloat)borderWidth
{
_borderWidth = borderWidth;
_backgroundLayer.lineWidth = borderWidth;
[self invalidateIntrinsicContentSize];
[self setNeedsDisplay];
}
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "M13ProgressSuite"
s.version = "1.2.8"
s.version = "1.2.9"
s.summary = "A suite containing many tools to display progress information on iOS."
s.description = <<-DESC
@@ -27,7 +27,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
s.platform = :ios, '7.0'
s.source = { :git => "https://github.com/Marxon13/M13ProgressSuite.git", :tag => "v1.2.8"}
s.source = { :git => "https://github.com/Marxon13/M13ProgressSuite.git", :tag => "v1.2.9"}
s.source_files = 'Classes/*/*'
+9 -9
View File
@@ -134,7 +134,7 @@
62BB86001C87300F0019306A /* UIApplication+M13ProgressSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIApplication+M13ProgressSuite.m"; path = "Classes/Application/UIApplication+M13ProgressSuite.m"; sourceTree = "<group>"; };
CA1C945C18CCF59500B469BF /* M13ProgressViewMetroDotPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = M13ProgressViewMetroDotPolygon.h; path = Classes/ProgressViews/M13ProgressViewMetroDotPolygon.h; sourceTree = "<group>"; };
CA1C945D18CCF59500B469BF /* M13ProgressViewMetroDotPolygon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = M13ProgressViewMetroDotPolygon.m; path = Classes/ProgressViews/M13ProgressViewMetroDotPolygon.m; sourceTree = "<group>"; };
CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = M13ProgressSuite.app; sourceTree = BUILT_PRODUCTS_DIR; };
CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = M13ProgressSuiteDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
CA2FAF9B1889907300BCAEF5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
CA2FAF9D1889907300BCAEF5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
CA2FAF9F1889907300BCAEF5 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
@@ -288,7 +288,7 @@
CA2FAF991889907300BCAEF5 /* Products */ = {
isa = PBXGroup;
children = (
CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */,
CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */,
CA2FAFBC1889907300BCAEF5 /* M13ProgressSuiteTests.xctest */,
FB2A7BDC1B793E5600FE4E4A /* M13ProgressSuite.framework */,
);
@@ -629,9 +629,9 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
CA2FAF971889907300BCAEF5 /* M13ProgressSuite */ = {
CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuite" */;
buildConfigurationList = CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuiteDemo" */;
buildPhases = (
CA2FAF941889907300BCAEF5 /* Sources */,
CA2FAF951889907300BCAEF5 /* Frameworks */,
@@ -643,9 +643,9 @@
dependencies = (
FB2A7BF21B793E5600FE4E4A /* PBXTargetDependency */,
);
name = M13ProgressSuite;
name = M13ProgressSuiteDemo;
productName = M13ProgressSuite;
productReference = CA2FAF981889907300BCAEF5 /* M13ProgressSuite.app */;
productReference = CA2FAF981889907300BCAEF5 /* M13ProgressSuiteDemo.app */;
productType = "com.apple.product-type.application";
};
CA2FAFBB1889907300BCAEF5 /* M13ProgressSuiteTests */ = {
@@ -714,7 +714,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
CA2FAF971889907300BCAEF5 /* M13ProgressSuite */,
CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */,
CA2FAFBB1889907300BCAEF5 /* M13ProgressSuiteTests */,
FB2A7BDB1B793E5600FE4E4A /* M13ProgressSuiteFramework */,
CA2FB0431889986D00BCAEF5 /* Documentation */,
@@ -834,7 +834,7 @@
/* Begin PBXTargetDependency section */
CA2FAFC21889907300BCAEF5 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CA2FAF971889907300BCAEF5 /* M13ProgressSuite */;
target = CA2FAF971889907300BCAEF5 /* M13ProgressSuiteDemo */;
targetProxy = CA2FAFC11889907300BCAEF5 /* PBXContainerItemProxy */;
};
FB2A7BF21B793E5600FE4E4A /* PBXTargetDependency */ = {
@@ -1112,7 +1112,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuite" */ = {
CA2FAFCD1889907300BCAEF5 /* Build configuration list for PBXNativeTarget "M13ProgressSuiteDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CA2FAFCE1889907300BCAEF5 /* Debug */,
File diff suppressed because it is too large Load Diff
@@ -1,17 +1,37 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "AppIcon29x29@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "AppIcon40x40@2x.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
@@ -24,6 +44,16 @@
"filename" : "AppIcon60x60@3x.png",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
@@ -59,6 +89,11 @@
"idiom" : "ipad",
"filename" : "AppIcon76x76@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
@@ -21,6 +21,7 @@
@property (nonatomic, retain) IBOutlet UISwitch *titleSwitch;
@property (nonatomic, retain) IBOutlet UIButton *finishButton;
@property (nonatomic, retain) IBOutlet UIButton *cancelButton;
@property (weak, nonatomic) IBOutlet UISwitch *clearBackgroundSwitch;
- (IBAction)animateProgress:(id)sender;
- (IBAction)progressChanged:(id)sender;
@@ -30,5 +31,7 @@
- (IBAction)secondaryColorChanged:(id)sender;
- (IBAction)finish:(id)sender;
- (IBAction)cancel:(id)sender;
- (IBAction)backgroundColorChanged:(id)sender;
- (IBAction)clearBackgroundChanged:(id)sender;
@end
@@ -33,6 +33,7 @@
{
[self.navigationController showProgress];
[super viewDidLoad];
[self.navigationController setBackgroundColor:[UIColor blackColor]];
// Do any additional setup after loading the view.
}
@@ -109,6 +110,23 @@
[self.navigationController cancelProgress];
}
- (IBAction)backgroundColorChanged:(id)sender
{
CGFloat red = (float)arc4random_uniform(256)/255.0;
CGFloat green = (float)arc4random_uniform(256)/255.0;
CGFloat blue = (float)arc4random_uniform(256)/255.0;
[self.navigationController setBackgroundColor:[UIColor colorWithRed:red green:green blue:blue alpha:1.0]];
}
- (IBAction)clearBackgroundChanged:(id)sender
{
if (_clearBackgroundSwitch.on) {
[self.navigationController setBackgroundColor:nil];
} else {
[self.navigationController setBackgroundColor:[UIColor blackColor]];
}
}
- (void)primaryColorChanged:(id)sender
{
CGFloat red = (float)arc4random_uniform(256)/255.0;
@@ -125,4 +143,6 @@
[self.navigationController setSecondaryColor:[UIColor colorWithRed:red green:green blue:blue alpha:1.0]];
}
@end