2013-07-03 158 views
2

我有一个NSComboBox显示不垂直对齐的文本。 有没有一种方法可以在NSComboBox中垂直对齐文本?NSComboBox垂直对齐

enter image description here

正如你所看到的,这是非常奇怪的,它并不字体大小的变化而变化。我搜索了NSComboBox Class Reference,但唯一可用的资源是用于弹出显示的项目(如intercellSpacingsetItemHeight:)。

预先感谢您。

回答

0

试试看:

NSComboBox* cbx = ZGKeyComboBox.new; 
// NSViewMaxYMargin means: The top margin between the receiver and its superview is flexible. 
cbx.autoresizingMask = NSViewMaxYMargin; 
cbx.itemHeight = cbx.itemHeight + 3; // addSubview will center vertically 
NSRect r = NSMakeRect(x, y, width, cbx.itemHeight + 5); 
cbx.frame = r; 
... 
[parent addSubview: cbx];