Draw shadow under NSImage

I am currently drawing an NSImage in a custom NSCell, for example:

- (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView *)theControlView {
    // roundedCornerImage creates a new NSImage with rounded corners, rather than clipping.
    [[anIcon roundedCornerImage:5] drawInRect:anIconBox fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}

      

It's very easy to wonder how to draw the image below it. On an iPhone, I would do this using CGContextSetShadow (currentContext, CGSizeMake(1, -1), 2)

:; just before drawing the UIImage, but I'm not familiar with how to do it on Mac.

Any pointers would be great.

+2


a source to share


1 answer


Look at the class NSShadow

. CGContextSetShadow

also exists on Mac, but it's a little harder to access the context itself.



+3


a source







All Articles