1

私はこの質問をしています:私は点の配列を持っており、この点によって石英または同様のもので不規則な多角形を描画します。これを作るための最良の方法を教えてもらえますか?

MyTest drawRect は次のとおりです。

- (void)drawRect:(CGRect)rect
{
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextClearRect(ctx, rect);

    CGContextSetRGBStrokeColor(ctx, 255, 0, 255, 1);
    CGPoint points[6] = { CGPointMake(100, 200), CGPointMake(150, 250),
        CGPointMake(150, 250), CGPointMake(50, 250),
        CGPointMake(50, 250), CGPointMake(100, 200) };
    CGContextStrokeLineSegments(ctx, points, 6);
}
4

1 に答える 1

3

UIBezierPath / NSBezierPath を使用できます。

UIBezierPath *poly = [[UIBezierPath alloc] init];
[poly moveToPoint:CGPointMake(0.0, 0.0)];
[poly addLineToPoint:CGPointMake(1.0, 0.0)];
[poly addLineToPoint:CGPointMake(1.0, 1.0)];
[poly closePath];
[poly stroke]; // draw stroke
[poly release];
于 2012-03-21T09:51:04.173 に答える