1
我想知道爲什麼我的窗口如下所示: 爲什麼用這段代碼(drawRect)渲染2行?
當我調整窗口的大小,一條線保持伸展而另一個保持靜態大小和傾斜。
奇怪的部分是,我記錄窗口的高度和寬度,每當drawRect
被調用。
我看着這個和意識到這是不實際的大小,移動窗口的大小了一下,得到真正結果。奇怪的是,它跳得如此之快。
奇怪的部分是「鬼」怎麼行仍然存在,我不知道哪一個是鬼!爲什麼?我改變了顯示線條的顏色...和:
這是靜態顯示的一個是被「產生」用我的每個代碼的drawRect之一。
我使用我的drawRect代碼:
- (void)drawRect:(NSRect)dirtyRect
{
NSLog(@"%f, %f", dirtyRect.size.height, dirtyRect.size.width);
NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(NSMaxX([self bounds]), NSMaxY([self bounds]))];
//Sorry about formatting; SO doesn't make it easy to format.
[line lineToPoint:NSMakePoint(NSMinX([self bounds]), NSMinY([self bounds]))];
[line setLineWidth:_lwith]; /// Make it easy to see
[_lineColor set]; /// Make future drawing the color of lineColor.
[line stroke];
}
我問了一些解釋,或者只是任何幫助!由於