The text of the text field is not displayed because you overwrite -drawRect and do not call [super drawRect:dirtyRect] in it.
In your case, I think that the easiest way to do what you want is to use a clip mask: just NSTextField do an ant drawing, then pin the area:
- (void)drawRect:(NSRect)dirtyRect { [NSGraphicsContext saveGraphicsState]; [[NSBezierPath bezierPathWithRoundedRect:dirtyRect xRadius:3.0 yRadius:3.0] setClip]; [super drawRect:dirtyRect]; [NSGraphicsContext restoreGraphicsState]; }
In general, it is better to subclass NSTextFieldCell instead to make a custom drawing, because the cells are responsible for drawing.
source share