Re: Applying a Drop Shadow to an NSView
Re: Applying a Drop Shadow to an NSView
- Subject: Re: Applying a Drop Shadow to an NSView
- From: August Trometer <email@hidden>
- Date: Tue, 15 Aug 2006 23:02:43 -0400
This should work for you. Keep in mind that you'll need to adjust both
the shadow parameters and the area that you're filling -- as I said,
you'll run up against the view's bounds and the shadow will get cut
off if you're not careful.
I also advise reading the docs...
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSShadow_Class/Reference/Reference.html
// create the shadow
NSShadow *dropShadow = [[[NSShadow alloc] init] autorelease];
[dropShadow setShadowColor:[NSColor blackColor]];
[dropShadow setShadowBlurRadius:5];
[dropShadow setShadowOffset:NSMakeSize(0,-3)];
// save graphics state
[NSGraphicsContext saveGraphicsState];
[dropShadow set];
// fill the desired area
[aRect fill];
// restore state
[NSGraphicsContext restoreGraphicsState];
// now do the rest of the drawing...
-- August
On Aug 15, 2006, at 10:43 PM, Tom Burns wrote:
Is there example code available that accomplishes this? I am in fact
implementing drawRect but would have no clue where to start with
this particular effect.
--Tom
On Aug 15, 2006, at 4:26 PM, August Trometer wrote:
It is my understanding that you cannot (currently) give a view a
shadow. If, however, you are custom drawing using the view's
drawRect: method, you can drop the shadow during the drawing. For
example, you can do a fill with a shadow. This may or may not
achieve the effect you're looking for. You'll also run up against
the view's bounds, so you'll need to take that into account.
-- August
On Aug 15, 2006, at 3:28 PM, Tom Burns wrote:
I have a custom view that I would like to display with a shadow.
The custom view is a subview of an NSBox, so it seems to me that
subclassing NSBox would be the proper course of action.
unfortunately, I was unable to find any example code for applying
shadows to views themselves, as opposed to their contents. Does
anyone have any advice for approaching this problem?
--Tom
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden