• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reverse-engineering Apple's two-tinted gradient NSViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reverse-engineering Apple's two-tinted gradient NSViews


  • Subject: Re: Reverse-engineering Apple's two-tinted gradient NSViews
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 22 Jan 2009 13:47:42 -0800


- (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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Reverse-engineering Apple's two-tinted gradient NSViews (From: Sam Krishna <email@hidden>)

  • Prev by Date: My objectcontroller is loosing its moc, but only with certain timing
  • Next by Date: Re: Using the security framework
  • Previous by thread: Re: Reverse-engineering Apple's two-tinted gradient NSViews
  • Next by thread: Re: OCUnit test failure - assert formatted text not presented
  • Index(es):
    • Date
    • Thread