- (void)drawRect:(NSRect)aRect { NSEraseRect(aRect); NSFont* font = [NSFont controlContentFontOfSize:[NSFont systemFontSize]]; NSColor* foreground = [NSColor blackColor]; NSColor* background = [NSColor blueColor]; NSNumber* underline = [NSNumber numberWithInt:NSUnderlineStyleSingle]; NSAttributedString* str = [[[NSAttributedString alloc] initWithString:@"Lorem ipsum dolor sit amet, consectetur adipisicing elit." attributes: [NSDictionary dictionaryWithObjectsAndKeys: font, NSFontAttributeName, foreground, NSForegroundColorAttributeName, background, NSBackgroundColorAttributeName, underline, NSUnderlineStyleAttributeName, nil]] autorelease]; CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; CGContextSetTextMatrix(context, CGAffineTransformMake(1, 0, 0, [self isFlipped] ? -1 : 1, 0, 0)); CGContextSetTextPosition(context, 10.0, 30.0); CTLineRef line = CTLineCreateWithAttributedString((CFAttributedStringRef)str); CTLineDraw(line, context); CFRelease(line); }