您的位置:首页 > 移动开发 > IOS开发

iOS下载进度条的实现

2016-06-26 00:00 537 查看
摘要: iOS下载进度条,经常在下载方面见到

#####下载进度条
#####1.下载进度条,经常在下载方面见到

1.和饼状态差不多,只不过只要注意结束角度的变化

#####2.实现也较为简单,代码

-(void) setEndValue:(CGFloat)endValue{
_endValue=endValue;
NSLog(@"%f",_endValue);
//重绘,系统会先创建与view相关联的上下文,然后再调用drawRect
[self setNeedsDisplay];
}
//注意:drawRect不能手动调用,因为图形上下文我们自己创建不了,只能由系统帮我们创建,并且传递给我们
- (void)drawRect:(CGRect)rect {
//NSLog(@"sss");
UIBezierPath *path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(rect.size.width*0.5, rect.size.height*0.5) radius:rect.size.height*0.5-2 startAngle:-M_PI_2 endAngle:-M_PI_2+ M_PI*2*self.endValue clockwise:YES];
[path stroke];
}

#####3.详细代码地址

github
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息