没有drawRect的Objective-C绘图:形状不会显示

|| 我有一个名为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]
    
已邀请:
        继续在
-drawRect:
中画图。发送
-drawRect:
时,将为您设置视图的坐标系和剪切边界,并且窗口的绘图上下文将为当前视图。 在该方法中,根据需要绘制尽可能多的圆圈。     

要回复问题请先登录注册