• 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: NSBezier Artifacts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBezier Artifacts


  • Subject: Re: NSBezier Artifacts
  • From: "John C. Randolph" <email@hidden>
  • Date: Sat, 26 Apr 2008 19:09:41 -0700


On Apr 25, 2008, at 10:18 PM, Aaron Wallis wrote:

I've been having a fair few issues with NSBezier boxes lately (a.k.a boxes with rounded corners)

I've created a NSView subclass that contains the following code, then threw a few on a window with some controls over the top:
- ( void ) drawRect: ( NSRect ) rect
{
NSBezierPath* thePath = [NSBezierPath bezierPath];
[thePath appendBezierPathWithRoundedRect:rect xRadius:10.0 yRadius:10.0];

Change the line above to:

[thePath appendBezierPathWithRoundedRect:[self bounds] xRadius:10.0 yRadius:10.0];

and you should get what you want, although it would still be less than ideal code.

Any ideas?

Several things. First, the rectangle you get as a parameter to - drawRect: is often smaller than the view recieving the message. The rect is given so that you don't have to draw the entire view every time. (See also -needsToDrawRect:, if you want to optimize this.) Second, figure out your drawing geometry in -setFrame:, not in - drawRect:. -drawRect: itself should be as little code as possible, because it can be invoked at any time.


-jcr


_______________________________________________

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: 
 >NSBezier Artifacts (From: Aaron Wallis <email@hidden>)

  • Prev by Date: Calculating file size
  • Next by Date: Re: How to import drawing paths into a Cocoa application?
  • Previous by thread: Re: NSBezier Artifacts
  • Next by thread: Not showing window at Document-Based application
  • Index(es):
    • Date
    • Thread