1又碌、按百分比畫圓弧度:
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:start endAngle:end clockwise:YES];
? ? ? ? ? ? [color set];
? ? ? ? ? ? [path addLineToPoint:center];
? ? ? ? ? ? [path fill];
2、添加圓心遮擋:
3、畫折線跟引線:
? ??//1.獲取上下文
? ? ? ? CGContextRef ctx = UIGraphicsGetCurrentContext();
? ? ? ? //2.繪制路徑
? ? ? ? UIBezierPath *path = [UIBezierPath bezierPath];
? ? ? ? [path moveToPoint:CGPointMake(endX, endY)];
? ? ? ? [path addLineToPoint:CGPointMake(breakPointX, breakPointY)];
? ? ? ? [path addLineToPoint:CGPointMake(startX, startY)];
? ? ? ? CGContextSetLineWidth(ctx, 0.5);
? ? ? ? //設(shè)置顏色
? ? ? ? [color set];
? ? ? ? //3.把繪制的內(nèi)容添加到上下文當(dāng)中
? ? ? ? CGContextAddPath(ctx, path.CGPath);
? ? ? ? //4.把上下文的內(nèi)容顯示到View上(渲染到View的layer)(stroke fill)
? ? ? ? CGContextStrokePath(ctx);
4肥荔、折線起始位置添加圓點您机;
5兔沃、在引線周圍添加文本。
注意事項:
1由境、當(dāng)前文本區(qū)域要跟前面所有文本區(qū)域比較是否有相交,相交后要調(diào)整當(dāng)前文本區(qū)域;
2虏杰、圖表內(nèi)的圓點讥蟆、文本、圓心遮擋纺阔、引線等既可以畫也可以添加View的方式瘸彤;
3、調(diào)整好圓弧半徑及文本區(qū)域高寬笛钝,避免界面遮擋质况。