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 (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 [EMAIL PROTECTED]

Reply via email to