| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // CircleView.m
- // IBOSS
- //
- // Created by guan hong hou on 2018/6/22.
- // Copyright © 2018年 elongtian. All rights reserved.
- //
- #import "CircleView.h"
- @implementation CircleView
- - (id)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setBackgroundColor:[UIColor whiteColor]];
- [self setNeedsDisplay];
-
- }
- return self;
- }
- /**
- * 画圆
- */
- -(void)drawRect:(CGRect)rect{
- // 1.获得上下文
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- //画圆
-
- CGContextSetFillColorWithColor(context,[UIColor hexColor:@"6acb9a"].CGColor);//填充颜色
- CGContextAddArc(context,80, 80, 60, 0, 2*M_PI, 0); //添加一个圆
- CGContextDrawPath(context, kCGPathFill); //填充路径
-
- CGContextRef context1 = UIGraphicsGetCurrentContext();
- CGContextSetLineWidth(context1,5);
- UIColor *lineColor = [UIColor hexColor:@"fecb6e"];
- CGContextSetStrokeColorWithColor(context1, lineColor.CGColor);//线框颜色
- //画圆
- double arc= M_PI*2*([_completePercent doubleValue]/100);
- CGContextAddArc(context1, 80, 80,62,M_PI/2*3 ,M_PI/2*3+arc, NO);
- //渲染
- CGContextStrokePath(context);
- }
- @end
|