Vertically center NSTextFieldCell?

I have an NSTableView where I change the row height with the following code:

- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row { return 32; } 

The problem is that my text cells are still aligned with the top of the cell, which makes it inconvenient. I could not understand how to vertically center it. Has anyone else found a solution?

+8
cocoa nstableview
source share
1 answer

See " Is there a" correct "way for NSTextFieldCell to draw vertically centered text? "

There is currently no easy way to use only the open API. The related question mentions that the undocumented field _cFlags.vCentered is the fastest way to work, although it is not supported and is not guaranteed to work correctly. Also, keep in mind that overriding methods will make your code different from what AppKit does.

I just filed a Radar for this:

http://openradar.appspot.com/9028329 Add an open API to vertically center text in NSCell


EDIT: Here are some additional related resources:

http://www.red-sweater.com/blog/148/what-a-difference-a-cell-makes

http://www.cocoabuilder.com/archive/cocoa/174994-repositioning-an-nstextfieldcell.html

+6
source share

All Articles