Thomas Szabo
Thomas Szabo

Reputation: 163

UI issues with custom NSBox

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

Upvotes: 1

Views: 272

Answers (1)

Thomas Szabo
Thomas Szabo

Reputation: 163

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

}

Upvotes: 2

Related Questions