解决了..如果有人正在寻找解决方案..这是指向正确答案的链接..以及代码片段。
所以提到的技巧是..在IB中添加一个常规文本字段..但将其单元格设置为CustomNSSecureTextFieldCell
在具有子类化的 NSSecureTextField 中垂直居中文本
@interface CustomNSSecureTextFieldCell : NSSecureTextFieldCell
@end
@implementation CustomNSSecureTextFieldCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSBezierPath *betterBounds = [NSBezierPath bezierPathWithRoundedRect:cellFrame xRadius:CORNER_RADIUS yRadius:CORNER_RADIUS];
[betterBounds addClip];
[super drawWithFrame:cellFrame inView:controlView];
if (self.isBezeled) {
[betterBounds setLineWidth:2];
[[NSColor colorWithCalibratedRed:0.510 green:0.643 blue:0.804 alpha:1] setStroke];
[betterBounds stroke];
}
}
@end