ポイント(または交点)が変化し、スライダーによって制御される UIBezierPath を使用して六角形を描画しています。お願いします。ここのスクリーンショットを参照してください: http://postimage.org/image/tq8z8t9qb/
ここでの問題は、最後のポイントが描画または移動されると、すでに間違っていることです(スクリーンショットを丸で囲みました)。ベジェパスの原点/中心点から余分な線が引かれていると思います。コードを確認していただければ幸いです:
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
CGPoint center = CGPointMake(150.0, 150.0);
// line
UIBezierPath *polyPath = [UIBezierPath bezierPath];
polyPath.lineWidth = 5;
[polyPath moveToPoint:CGPointMake(center.x, center.y + 60.0)];
for (int i = 1; i <= 6; ++i) {
CGFloat x, y;
NSNumber *oNumb = [[self aIndexValues] objectAtIndex:i-1];
fXValue_ = [oNumb floatValue];
x = fXValue_ * sinf(i * 2.0 * M_PI / 6.0);
y = fXValue_ * cosf(i * 2.0 * M_PI / 6.0);
[polyPath addLineToPoint:CGPointMake(center.x + x, center.y + y)];
}
[polyPath closePath];
[[UIColor redColor] setStroke];
[polyPath stroke];
// circle point
for(int i = 1; i <= 6; ++i) {
CGFloat x, y;
NSNumber *oNumb = [[self aIndexValues] objectAtIndex:i-1];
fXValue_ = [oNumb floatValue];
x = fXValue_ * sinf(i * 2.0 * M_PI / 6.0);
y = fXValue_ * cosf(i * 2.0 * M_PI / 6.0);
UIBezierPath *circle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(center.x + x - 6, center.y + y - 6, 15, 15)];
circle.lineWidth = 5;
[[UIColor whiteColor] setFill];
[circle fill];
}
}
お願いします。何が悪いのか教えてください。ありがとう