diff --git a/PICircularProgressView/PICircularProgressView.h b/PICircularProgressView/PICircularProgressView.h index 8c69608..b8b627b 100644 --- a/PICircularProgressView/PICircularProgressView.h +++ b/PICircularProgressView/PICircularProgressView.h @@ -8,9 +8,15 @@ #import +typedef NS_ENUM(NSUInteger, PICircularProgressStringFormat) { + PICircularProgressStringFormatPlain, + PICircularProgressStringFormatPercent +}; + @interface PICircularProgressView : UIView @property (nonatomic) double progress; +@property (assign, nonatomic) PICircularProgressStringFormat stringFormat; // Should be BOOLs, but iOS doesn't allow BOOL as UI_APPEARANCE_SELECTOR @property (nonatomic) NSInteger showText UI_APPEARANCE_SELECTOR; diff --git a/PICircularProgressView/PICircularProgressView.m b/PICircularProgressView/PICircularProgressView.m index 90a2c49..c34fe0b 100644 --- a/PICircularProgressView/PICircularProgressView.m +++ b/PICircularProgressView/PICircularProgressView.m @@ -123,7 +123,17 @@ - (void)drawRect:(CGRect)rect if (_showText && _textColor) { - NSString *progressString = [NSString stringWithFormat:@"%.0f", _progress * 100.0]; + NSString *progressString; + switch (_stringFormat) { + case PICircularProgressStringFormatPercent: { + progressString = [NSString stringWithFormat:@"%.0f%%", _progress * 100.0]; + break; + } + default: { + progressString = [NSString stringWithFormat:@"%.0f", _progress * 100.0]; + break; + } + } CGFloat fontSize = radius; UIFont *font = [_font fontWithSize:fontSize];