0

我有一个名为 mapWindow 的类,它连接到 IB 中的一个窗口。

无论如何,除非代码在 drawRect 下或我移动窗口边框,否则我希望程序渲染的红色圆圈不会出现。甚至解锁和锁定焦点都不会更新窗口。

theOtherWindowView 实际上是一个连接到 IB 中的自定义视图的 NSView。

- (void)test
{
    [theOtherWindowView lockFocus];
    NSBezierPath *path = [NSBezierPath bezierPath];
    NSPoint center = [self drawPoint];
    [path moveToPoint: center];
    [path appendBezierPathWithArcWithCenter:center
                                        radius:explosionRadius
                                    startAngle:0
                                    endAngle:360];
    [[NSColor redColor] set];
    [path fill];

    [theOtherWindowView unlockFocus];
}

不想使用 drawRect 因为我想要多个实例而不是一个形状,它的坐标每次更新都会改变。

我也试过[self lockFocus][mapWindow lockFous]

4

1 回答 1

2

继续画-drawRect:。发送时-drawRect:,您的视图坐标系和剪裁边界将为您设置好,并且您的窗口的绘图上下文将是当前的。

在该方法中,根据需要绘制尽可能多的这些圆圈。

于 2011-06-13T05:45:20.450 回答