Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions PICircularProgressView/PICircularProgressView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@

#import <UIKit/UIKit.h>

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;
Expand Down
12 changes: 11 additions & 1 deletion PICircularProgressView/PICircularProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down