I'd like the NSTextFields I set up in Interface Builder to have shadows. I've implemented a way to do this which seems to work, but I'm not sure if it's the right way.
What I did is subclass NSTextFieldCell as follows and then set my subclass as the NSTextField's cell's type in IB. Is there a problem with this approach? Is there a better way?
#import "ShadowTextFieldCell.h"
static NSShadow *kShadow = nil;
@implementation ShadowTextFieldCell
+ (void)initialize
{
kShadow = [[NSShadow alloc] init];
[kShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.f alpha:0.08f]];
[kShadow setShadowBlurRadius:0.f];
[kShadow setShadowOffset:NSMakeSize(0.f, -2.f)];
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[kShadow set];
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
@end