观看本节, 你可能需要先了解
一.核心部分
/**
* 圆点坐标: center, 半径: radius, 角度: angle
*/
- (CGPoint)pointOfCircleWithCenter:(CGPoint)center angle:(CGFloat)angle radius:(CGFloat)radius {
//(angle*M_PI)/180, 弧度与角度转换
CGFloatx = center.x+ radius*cos(angle);
CGFloaty = center.y+ radius*sin(angle);
returnCGPointMake(x, y);
}
二.计算等边多边形路径
NSMutableArray *pointArr = [NSMutableArray array];
for(inti=0; i<5; i++) {//五边形
CGPointpoint = [self pointOfCircleWithCenter:CGPointMake(100,100) angle:((M_PI*2)/5)*i radius:100];
[pointArr addObject:NSStringFromCGPoint(point)];
}
UIBezierPath *path = [UIBezierPath bezierPath];
for(inti=0; i
if(i ==0) {
[path moveToPoint:CGPointFromString(pointArr[i])];
}
else{
[path addLineToPoint:CGPointFromString(pointArr[i])];
}
}
[path closePath];
绘制完贝赛尔曲线路径后, 剩下就呈现到界面即可