UI issues with custom NSBox

276 Views Asked by At

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

1

There are 1 best solutions below

0
Thomas Szabo On BEST ANSWER

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];

}