I have some variable text in an NSTextField
that renders on a CALayer
background view. As a CALayer
does not support sub-pixel aliasing fo
Here is how the Original poster did not want to do it, but it was OK for me to have an opaque background...
when you make the layer:
layer.opaque = YES;
Then in
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
[NSGraphicsContext saveGraphicsState];
NSGraphicsContext *nscg = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
[NSGraphicsContext setCurrentContext:nscg];
NSRect ourframe = self.frame;
// white background enables antialiasing
[[NSColor whiteColor] setFill];
NSRect ourNSFrame = ourframe;
ourNSFrame.origin = NSZeroPoint;
NSRectFill(ourNSFrame);
[sometext drawInRect:ourNSFrame withAttributes:someattrs];
[NSGraphicsContext restoreGraphicsState];