這一篇,我們將繪制一多花。
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.附上圓弧圖紙一張