- (void)drawRect:(NSRect)rect {
// Drawing code here.
NSArray *_colorArray = [NSArray arrayWithObjects:
[NSColor colorWithDeviceRed:0.9843 green:
0.9843 blue:0.9843 alpha:1.0],
[NSColor colorWithDeviceRed:0.9608 green:
0.9608 blue:0.9608 alpha:1.0],
[NSColor colorWithDeviceRed:0.8824 green:
0.8824 blue:0.8824 alpha:1.0],
nil];
NSGradient *_gradient = [[NSGradient alloc]
initWithColors:_colorArray];
[_gradient drawInRect:rect angle:90];
[_gradient release];
}
No one else pointed it out, and it is good practice to understand what
is wrong with your code.
'rect' in drawRect: is the dirty rect, which may or may the entire
bounds. For a gradient, you can't refill just the dirty rect.
Therefore, you must use self.bounds. Brandon's example shows this.
corbin
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com