Skip to content
Open
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
18 changes: 6 additions & 12 deletions SDProgressView/Classes/Lib/SDBaseProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#import "SDBaseProgressView.h"

@implementation SDBaseProgressView
@synthesize progress = _progress;

- (id)initWithFrame:(CGRect)frame
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = SDProgressViewBackgroundColor;
Expand All @@ -24,20 +25,16 @@ - (void)setProgress:(CGFloat)progress
{
_progress = progress;

if (progress >= 1.0) {
[self removeFromSuperview];
} else {
if (progress < 1.0) {
[self setNeedsDisplay];
}

}

- (void)setCenterProgressText:(NSString *)text withAttributes:(NSDictionary *)attributes
{
CGFloat xCenter = self.frame.size.width * 0.5;
CGFloat yCenter = self.frame.size.height * 0.5;

// 判断系统版本
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
CGSize strSize = [text sizeWithAttributes:attributes];
CGFloat strX = xCenter - strSize.width * 0.5;
Expand All @@ -59,20 +56,17 @@ - (void)setCenterProgressText:(NSString *)text withAttributes:(NSDictionary *)at

[attrStr drawAtPoint:CGPointMake(strX, strY)];
}



}

// 清除指示器
- (void)dismiss
{
self.progress = 1.0;
[self removeFromSuperview];
}

+ (id)progressView
+ (instancetype)progressView
{
return [[self alloc] init];
return [self new];
}

@end