Skip to content

Commit

Permalink
Fixed Issue #32, and Added a new progress view.
Browse files Browse the repository at this point in the history
  • Loading branch information
NinjaKittenProductions committed Apr 30, 2014
1 parent 9d3c309 commit 6ea8d8d
Show file tree
Hide file tree
Showing 12 changed files with 799 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,17 @@
- (void)cancelProgress;
/**Wether or not the progress bar is showing.*/
- (BOOL)isShowingProgressBar;
/**
The primary color of the progress bar if you do not want it to be the same as the UINavigationBar's tint color. If set to nil, the UINavigationBar's tint color will be used.
@param primaryColor The color to set.
*/
- (void)setPrimaryColor:(UIColor *)primaryColor;
/**
The secondary color of the progress bar, if nil, the secondary color will be the barTintColor.
@param secondaryColor The color to set.
*/
- (void)setSecondaryColor:(UIColor *)secondaryColor;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
static char indeterminateKey;
static char indeterminateLayerKey;
static char isShowingProgressKey;
static char primaryColorKey;
static char secondaryColorKey;

@implementation UINavigationController (M13ProgressViewBar)

Expand Down Expand Up @@ -156,6 +158,9 @@ - (void)updateProgressWithInterfaceOrientation:(UIInterfaceOrientation)interface
{
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];
}
Expand Down Expand Up @@ -243,11 +248,32 @@ - (void)drawIndeterminateWithInterfaceOrientation:(UIInterfaceOrientation)interf
//Start the image context
UIGraphicsBeginImageContextWithOptions(CGSizeMake(stripeWidth * 4.0, stripeWidth * 4.0), NO, [UIScreen mainScreen].scale);
//Fill the background
if ([self getPrimaryColor]) {
[[self getPrimaryColor] setFill];
} else {
[self.navigationBar.tintColor setFill];
}
UIBezierPath *fillPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, stripeWidth * 4.0, stripeWidth * 4.0)];
[fillPath fill];
//Draw the stripes
[self.navigationBar.barTintColor setFill];
//Set the stripe color
if ([self getSecondaryColor]) {
[[self getSecondaryColor] setFill];
} else {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
[self.navigationBar.barTintColor getRed:&red green:&green blue:&blue alpha:&alpha];
//System set the tint color to a close to, but not non-zero value for each component.
if (alpha > .05) {
[self.navigationBar.barTintColor setFill];
} else {
[[UIColor whiteColor] setFill];
}

}

for (int i = 0; i < 4; i++) {
//Create the four inital points of the fill shape
CGPoint bottomLeft = CGPointMake(-(stripeWidth * 4.0), stripeWidth * 4.0);
Expand Down Expand Up @@ -423,4 +449,27 @@ - (BOOL)isShowingProgressBar
return objc_getAssociatedObject(self, &isShowingProgressKey);
}

- (void)setPrimaryColor:(UIColor *)primaryColor
{
objc_setAssociatedObject(self, &primaryColorKey, primaryColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self getProgressView].backgroundColor = primaryColor;
[self setIndeterminate:[self getIndeterminate]];
}

- (UIColor *)getPrimaryColor
{
return objc_getAssociatedObject(self, &primaryColorKey);
}

- (void)setSecondaryColor:(UIColor *)secondaryColor
{
objc_setAssociatedObject(self, &secondaryColorKey, secondaryColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self setIndeterminate:[self getIndeterminate]];
}

- (UIColor *)getSecondaryColor
{
return objc_getAssociatedObject(self, &secondaryColorKey);
}

@end
47 changes: 47 additions & 0 deletions Classes/ProgressViews/M13ProgressViewLetterpress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// M13ProgressViewLetterpress.h
// M13ProgressSuite
//
// Created by Brandon McQuilkin on 4/28/14.
// Copyright (c) 2014 Brandon McQuilkin. All rights reserved.
//

#import "M13ProgressView.h"

typedef enum {
M13ProgressViewLetterpressPointShapeSquare,
M13ProgressViewLetterpressPointShapeCircle
} M13ProgressViewLetterpressPointShape;

@interface M13ProgressViewLetterpress : M13ProgressView
/**@name Properties*/
/**
The number of grid points in each direction.
*/
@property (nonatomic, assign) CGPoint numberOfGridPoints;
/**
The shape of the grid points.
*/
@property (nonatomic, assign) M13ProgressViewLetterpressPointShape pointShape;
/**
The amount of space between the grid points.
*/
@property (nonatomic, assign) CGFloat pointSpacing;
/**
The size of the notch to carve out on one side.
*/
@property (nonatomic, assign) CGSize notchSize;
/**
The spring constant that defines the amount of "spring" the progress view has in its animation.
*/
@property (nonatomic, assign) CGFloat springConstant;
/**
The constant that determines how long the progress view "bounces" for.
*/
@property (nonatomic, assign) CGFloat dampingCoefficient;
/**
The constant that determines how much the springConstant and dampingCoefficent affect the animation.
*/
@property (nonatomic, assign) CGFloat mass;

@end
Loading

0 comments on commit 6ea8d8d

Please sign in to comment.