仿新浪微博圖片加載進度條

JLPieProgressView

仿新浪微博圖片加載進度條
實現代碼如下:

#import "JLPieProgressView.h"

@implementation JLPieProgressView

- (void)setProgressValue:(CGFloat)progressValue{
    
    _progressValue = progressValue;
    
    //重繪
    [self setNeedsDisplay];
    
}

- (void)drawRect:(CGRect)rect {
    
    //開始角度
    CGFloat startAngle = -M_PI/2;
    //結束角度
    CGFloat endAngle = startAngle+M_PI*2*_progressValue;
    
    CGFloat smallRadius = 10;//內圓半徑
    CGFloat bigRadius = smallRadius*2+2;//外圓半徑
    
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    
    //畫外圓
    [[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.8] set];
    CGContextAddArc(ctx, rect.size.width/2, rect.size.height/2,bigRadius,0 , M_PI*2, 0);
    CGContextStrokePath(ctx);
    
    //畫內圓
    CGContextSetLineWidth(ctx, smallRadius*2);
    CGContextAddArc(ctx, rect.size.width/2, rect.size.height/2, smallRadius,startAngle , endAngle, 0);
    CGContextStrokePath(ctx);
    
}
效果圖

下載點擊源代碼

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容