I have an NSTableView where I am changing the height of the rows with the following code:
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
return 32;
}
The problem is, my text cells are still being aligned to the top of the cell, making it look awkward. I havent been able to figure out how to vertically center it. Has anyone else found a solution to this?
See "Is there a “right” way to have NSTextFieldCell draw vertically centered text?"
There is currently no easy way using only public API. The question linked above mentions that the undocumented _cFlags.vCentered
field is the quickest path to making it work, although it's unsupported and isn't guaranteed to work correctly. Also, be aware that overriding methods will cause your code to diverge from what AppKit does.
I just filed a Radar for this:
http://openradar.appspot.com/9028329 Add public API for vertically centering 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With