自从升级到 10.9 Mavericks 后,我注意到所有NSSearchfield
实例的内容都没有对齐:放大镜图标、文本字段本身和清除按钮都向下移动了一点。
知道可能是什么原因吗?
自从升级到 10.9 Mavericks 后,我注意到所有NSSearchfield
实例的内容都没有对齐:放大镜图标、文本字段本身和清除按钮都向下移动了一点。
知道可能是什么原因吗?
我暂时可以通过子类化NSSearchField
并选择一个自定义类作为单元类来修复它:
+ (void) load {
[super load];
[self setCellClass:[RMSearchFieldCell class]];
}
RMSearchFieldCell
通过覆盖searchTextRectForBounds:
,searchButtonRectForBounds:
和cancelButtonRectForBounds:
方法将单元格的原点移动 +1:
- (NSRect) cancelButtonRectForBounds:(NSRect)rect {
NSRect superRect = [super cancelButtonRectForBounds:rect];
superRect.origin.y -=1;
return superRect;
}
然而,这不是优雅的做法,我仍在寻找错位的原因。