diff --git a/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.h b/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.h index 25dd443..25a78e1 100644 --- a/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.h +++ b/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.h @@ -47,6 +47,12 @@ */ @property (readwrite) BOOL hideProgressIcons; +/** + * Use the play icond instead of the download icon + */ +@property (readwrite) BOOL usePlayIcon; + + /** * Make the background layer to spin around its center. This should be called in the main thread. */ diff --git a/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.m b/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.m index 38fede8..5884ce7 100644 --- a/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.m +++ b/FFCircularProgressView/FFCircularProgressView/FFCircularProgressView.m @@ -22,6 +22,7 @@ @implementation FFCircularProgressView #define kArrowSizeRatio .12 #define kStopSizeRatio .3 #define kTickWidthRatio .3 +#define kPlaySizeRatio .4 - (id)initWithFrame:(CGRect)frame { @@ -133,8 +134,13 @@ - (void)drawRect:(CGRect)rect } else { if (!self.iconView && !self.iconPath) { - if (!_hideProgressIcons) - [self drawArrow]; + if (!_hideProgressIcons) { + if(_usePlayIcon) + [self drawPlay]; + else + [self drawArrow]; + } + } else if (self.iconPath) { @@ -258,6 +264,25 @@ - (void) drawArrow { _iconLayer.fillColor = nil; } +- (void) drawPlay { + CGFloat radius = (self.bounds.size.width)/2; + CGFloat ratio = kPlaySizeRatio; + CGFloat sideSize = self.bounds.size.width * ratio; + + UIBezierPath *stopPath = [UIBezierPath bezierPath]; + [stopPath moveToPoint:CGPointMake(.25*sideSize, 0)]; + [stopPath addLineToPoint:CGPointMake(sideSize, .5*sideSize)]; + [stopPath addLineToPoint:CGPointMake(.25*sideSize, sideSize)]; + [stopPath closePath]; + + // ...and move it into the right place. + [stopPath applyTransform:CGAffineTransformMakeTranslation(radius * (1-ratio), radius* (1-ratio))]; + + [_iconLayer setPath:stopPath.CGPath]; + [_iconLayer setStrokeColor:_progressLayer.strokeColor]; + [_iconLayer setFillColor:self.tintColor.CGColor]; +} + #pragma mark Setters - (void)setProgress:(CGFloat)progress {