1

I have a subclassed NSBox. Inside I have some NSTextfields embedded, which show some strange artifacts in their corners (see image here). This is my subclass code for the NSBox:

    - (void)drawRect:(NSRect)rect {
    NSBezierPath* rectanglePath = [NSBezierPath bezierPathWithRoundedRect:rect
                                                                  xRadius: 4
                                                                  yRadius: 4];
    [NSColor whiteColor];
    [rectanglePath fill];
}

Any ideas? Thanks, Thomas

Thomas Szabo
  • 163
  • 7
  • Why are you using NSBox, if you are adding TextFields to it? Past a point, it would seem to make more sense to just use NSView. – stevesliva Feb 19 '15 at 04:34
  • 1
    stevesliva, I removed the NSBox and replaced it with a subclassed NSView. Same results. But when I checked Core Animation Layer in the View Effects Inspector these drawing issues disappeared. I do not understand what´s happening here. – Thomas Szabo Feb 19 '15 at 18:58
  • I'd update your title and tags... you might get some more responses with the Core Animation query. – stevesliva Feb 19 '15 at 20:09
  • Sheen, this did not help. Artifacts are still there. – Thomas Szabo Feb 24 '15 at 12:44

1 Answers1

2

What solved the problem was using [self bounds] instead of the rect argument.

- (void)drawRect:(NSRect)rect {
NSBezierPath* rectanglePath = [NSBezierPath bezierPathWithRoundedRect:[self bounds]
                                                              xRadius: 4
                                                              yRadius: 4];
[NSColor whiteColor];
[rectanglePath fill];

}

Thomas Szabo
  • 163
  • 7