私は多くの座標x、yNSApplicationDelegate
を入力するクラスを持っています。NSMutableArray *coordinate
NSView
配列内にすべてを描画するようにクラスに指示するにはどうすればよいですか? 配列を NSView クラスに渡すにはどうすればよいですか?
ありがとうございました。
私は多くの座標x、yNSApplicationDelegate
を入力するクラスを持っています。NSMutableArray *coordinate
NSView
配列内にすべてを描画するようにクラスに指示するにはどうすればよいですか? 配列を NSView クラスに渡すにはどうすればよいですか?
ありがとうございました。
座標が配列にどのように格納されているかによって異なりますが、おそらく次のように作成する必要がありますNSBezierPath
。
// Maybe make bezPath an instance variable of your view?
NSBezierPath *bezPath = [NSBezierPath bezierPath];
[bezPath setLineWidth:1.0];
// set up other parameters here
[bezPath moveToPoint:NSMakePoint(firstX, firstY)];
// loop over your source coordinates
for (i = 0; i < ... etc ...)
{
[bezPath lineToPoint:NSMakePoint(source[i].x, source[i].y)];
}
NSView のサブクラスのdrawRect:
メソッドでは、次のようなものを使用できます。
- (void) drawRect:(NSRect) dirtyRect
{
[[NSColor blackColor] set];
[bezPath stroke];
}
十分な情報が提供されていないため、このコードの大部分が欠落していますが、おそらく正しい方向に導くCocoa Drawing Guideを見てください。