drawRect方法实现进度条progress

来源:互联网 发布:下载隐藏软件 编辑:程序博客网 时间:2024/06/05 02:04

- (void)drawRect:(CGRect)rect {

CGContextRef context=UIGraphicsGetCurrentContext();//获得画图环境

CGContextSetLineWidth(context, 10.0);//线条粗细

CGContextSetStrokeColorWithColor(context, [[UIColor colorWithRed:101.0/255.0 green:144.0/255.0 blue:220.0/255.0 alpha:1.0CGColor]);//画笔色

CGContextSetFillColorWithColor(context, [[UIColor clearColorCGColor]);//填充色

CGContextAddArc(context, 10010020, -M_PI/2.0endAngle*M_PI-M_PI/2.00);//从最上端开始顺时针画圈

CGContextDrawPath(context, kCGPathFillStroke);

}

- (void)viewDidLoad {

    [super viewDidLoad];

ball=[[Ball allocinitWithFrame:CGRectMake(0.00.0200200)];

[self.view addSubview:ball];

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timerHandler:) userInfo:nil repeats:YES];

}

-(void)timerHandler:(NSTimer*)timer

{

if (ball.endAngle < 1.9) {

ball.endAngle=ball.endAngle+0.1;

}

[ball setNeedsDisplay];

[ball move];

}

原创粉丝点击