这一篇,我们将绘制一多花。
1.当我们要绘制的图形比较复杂,我们要先分析图形怎样拆分。(我想的是他是有四个半圆组成的,所以我们可以想成它是由四嵌在中间正方形上的4个半圆)
2.所以我们只要得到以下四个点的坐标就能轻松绘制了
3.开始绘制吧:
#define pi 3.14159265359
#define DEGREES_TO_RADIANS(degrees) ((pi * degrees)/ 180)
- (void)drawRect:(CGRect)rect{
UIColor *color = [UIColor redColor];
[color set];
UIBezierPath *path = [UIBezierPath bezierPath];
[path addArcWithCenter:CGPointMake(200, 250) radius:50 startAngle:DEGREES_TO_RADIANS(90) endAngle:DEGREES_TO_RADIANS(270) clockwise:YES];//参数1-圆心,2-弧度,3-圆弧起点,4-圆弧终点
[path addArcWithCenter:CGPointMake(250, 200) radius:50 startAngle:DEGREES_TO_RADIANS(180) endAngle:0 clockwise:YES];
[path addArcWithCenter:CGPointMake(300, 250) radius:50 startAngle:DEGREES_TO_RADIANS(270) endAngle:DEGREES_TO_RADIANS(90) clockwise:YES];
[path addArcWithCenter:CGPointMake(250, 300) radius:50 startAngle:0 endAngle:DEGREES_TO_RADIANS(180) clockwise:YES];
path.lineWidth = 5;
[path fill];
}
4.附上圆弧图纸一张