Because, I need some advanced menubar item, I'm using custom NSView subclass as a view for menubaritem.
In drawrect I'm drawing some simple nsimage, and It works fine with normal displays, but on retina displays, it loads smaller image (yes, I have @2x artwork).
Code:
- (void)drawRect:(NSRect)dirtyRect
{
[self.statusItem drawStatusBarBackgroundInRect:dirtyRect withHighlight:self.isHighlighted];
[icon scalesWhenResized];
icon = self.isHighlighted ? self.alternateImage : [images objectAtIndex:index];
NSSize iconSize = [icon size];
NSRect bounds = self.bounds;
CGFloat iconX = roundf((NSWidth(bounds) - iconSize.width) / 2);
CGFloat iconY = roundf((NSHeight(bounds) - iconSize.height) / 2);
NSPoint iconPoint = NSMakePoint(iconX, iconY);
[icon drawAtPoint:iconPoint fromRect:bounds operation:NSCompositeSourceOver fraction:1];
}
I tested it with Quartz Debug and on real Retina Macbooks, everything is fine except this little image in menubar.
Update:
self.images = [NSArray arrayWithObjects:[NSImage imageNamed:@"1.png"],[NSImage imageNamed:@"2.png"],[NSImage imageNamed:@"3.png"],[NSImage imageNamed:@"4.png"],[NSImage imageNamed:@"5.png"],[NSImage imageNamed:@"6.png"],[NSImage imageNamed:@"7.png"],[NSImage imageNamed:@"8.png"],[NSImage imageNamed:@"9.png"],[NSImage imageNamed:@"10.png"],[NSImage imageNamed:@"11.png"],[NSImage imageNamed:@"12.png"],[NSImage imageNamed:@"13.png"],[NSImage imageNamed:@"14.png"],[NSImage imageNamed:@"15.png"],[NSImage imageNamed:@"16.png"],[NSImage imageNamed:@"17.png"],[NSImage imageNamed:@"18.png"],[NSImage imageNamed:@"19.png"],[NSImage imageNamed:@"20.png"],[NSImage imageNamed:@"21.png"],[NSImage imageNamed:@"22.png"],[NSImage imageNamed:@"23.png"],[NSImage imageNamed:@"24.png"],[NSImage imageNamed:@"25.png"],[NSImage imageNamed:@"26.png"],
nil];