I m trying to draw at the top of my NSView
which has some subviews.
In fact I m trying to reproduce the connection line style of Interface Builder. Here is the code I m using for the moment:
- (void)drawRect:(CGRect)dirtyRect
{
// Background color
[[NSColor whiteColor] setFill];
NSRectFill(dirtyRect);
// Draw line
if(_connecting)
{
CGContextRef c = [[NSGraphicsContext currentContext] graphicsPort];
[[NSColor redColor] setStroke];
CGContextMoveToPoint(c, _start.x, _start.y);
CGContextAddLineToPoint(c, _end.x, _end.y);
CGContextSetLineWidth(c, LINE_WIDTH);
CGContextClosePath(c);
CGContextStrokePath(c);
}
}
第一部分是仿照我的<代码>。 页: 1 (如果你知道另一种方式,请告诉我,原因一来自“i”开发公司,而我错了backgroundColor
property of View
Then if a connection if detected, I draw it with 2 NSPoint
s. This code works but I didn t get it to draw over subviews, only on the first NSView
.