0

「appendBezierPathWithArcFromPoint」を使用して描画と円弧を作成しようとしていますが、実行すると円弧が描画されません。「lineToPont」が機能し、他の「NSBezierPath」コマンドが機能します。私が間違っていることを教えてください。私は明確な答えなしでかなりの検索をしました。MAC OS 10.9.2 と XCode 5.1 を使用しています。以下はコードのスニペットです。ありがとうございました。

#import "MyView.h"

@implementation MyView

- (id)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    // Initialization code here.
}
    return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
    [super drawRect:dirtyRect];

    NSRect bounds = [self bounds];

    NSBezierPath *thePath = [NSBezierPath bezierPath]; // all drawing instruction goes to thePath.
    [NSBezierPath setDefaultLineWidth:2.0];
    [[NSColor blackColor] set];
    [thePath moveToPoint:NSMakePoint(0, 0)];
    [thePath lineToPoint:NSMakePoint(100, 30)];
    [thePath appendBezierPathWithArcFromPoint:NSMakePoint(100,30)  toPoint:NSMakePoint(130,0) radius:30];
    [thePath stroke];

} 
@end
4

1 に答える 1

0

ドキュメントを見ると、あなたfromPointが現在のポイントに等しいことが問題のようです。ドキュメントは言う:

作成される円弧は、現在の点、fromPoint パラメータ、toPoint パラメータの 3 点 (この順序) によって指定される角度の内側に内接する円によって定義されます。

fromPointということは、現状とは違うはずだということだと思います。

于 2014-04-17T04:11:03.983 に答える