开发者

Vertically center NSTextFieldCell?

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,开发者_如何学Go 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜