NSShadow を使用した NSTextField
// Modify theTextField so that its NSShadow will be visible.
theTextField.wantsLayer = YES ;
theTextField.bezeled = NO ;
theTextField.drawsBackground = NO ;
NSShadow* redShadow = [NSShadow new] ;
redShadow.shadowOffset = NSMakeSize(2, 2) ;
redShadow.shadowColor = [NSColor redColor] ;
theTextField.shadow = redShadow ;
その結果、次のようになります。 
NSShadows と NSTextFields/NSSearchFields での私の経験では、NSTextField がベゼルで囲まれておらず、その背景を描画しない限り、影は表示されず、点滅するカーソルはその前のテキストと共に影になります。
編集:
サブクラス NSSearchField、オーバーライドdrawRect:
- (void) drawRect:(NSRect)dirtyRect {
NSShadow* redShadow = [NSShadow new] ;
redShadow.shadowOffset = NSMakeSize(2, -2) ;
redShadow.shadowColor = [NSColor redColor] ;
[NSGraphicsContext saveGraphicsState] ;
self.wantsLayer = YES ; // or NO
[redShadow set] ;
[super drawRect:dirtyRect] ;
[NSGraphicsContext restoreGraphicsState] ;
}
その結果:
. 虫眼鏡アイコンや X ボタンに影を付けたくない場合は、次のようにします。
元の NSSearchField の後ろに 2 つ目の NSSearchField を追加します
これはおそらく Interface Builder で行う方が簡単ですが、NSSearchField サブクラスでこれを行うコードを次に示します。
- (void) awakeFromNib {
[super awakeFromNib] ;
NSSearchField* shadowSearchField = [NSSearchField new] ;
[self.superview addSubview:shadowSearchField positioned:NSWindowBelow relativeTo:self ] ;
shadowSearchField.translatesAutoresizingMaskIntoConstraints = NO ;
shadowSearchField.editable = NO ;
float horizontalOffset = -2 ;
float verticalOffset = -2 ;
[self.superview addConstraint: [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:shadowSearchField attribute:NSLayoutAttributeLeading multiplier:1 constant:horizontalOffset ] ] ;
[self.superview addConstraint: [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:shadowSearchField attribute:NSLayoutAttributeTop multiplier:1 constant:verticalOffset ] ] ;
[self.superview addConstraint: [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:shadowSearchField attribute:NSLayoutAttributeWidth multiplier:1 constant:0 ] ] ;
[self.superview addConstraint: [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:shadowSearchField attribute:NSLayoutAttributeHeight multiplier:1 constant:0 ] ] ;
}
その結果:
と が得られ
ます。これは、2 番目の NSSearchField の位置と色を微調整できれば、希望するものに最も近いと思われます。