私は次のコードを書いています。ブールが真の後、私はrectに図面を追加します。ここに私が持っているコードですが、何らかの理由でboolを設定していないか、setNeedsDisplayを呼び出していません。私は他のクラスを正しく参照していますか? cutoutView.mブールを別のクラスに設定する
で感謝// AppController.m
で-(IBAction)colorToggle:(id)sender
{
if ([colorFilter state] == NSOnState)
{
CutoutView *theView = [[CutoutView alloc] init];
[theView setFilterEnabled:YES];
}
}
//
- (void)drawRect:(NSRect)dirtyRect
{
[[[NSColor blackColor]colorWithAlphaComponent:0.9]set];
NSRectFill(dirtyRect);
//this is what i want to be drawn when my bool is true and update the drawRect
if (filterEnabled == YES) {
NSRectFillUsingOperation(NSMakeRect(100, 100, 300, 300), NSCompositeClear);
[self update];
}
}
-(void)update
{
[self setNeedsDisplay:YES];
}
ありがとう!完璧な意味合いを持つ –