vertically aligning text in NSTableView row

前端 未结 4 1091
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 12:47

I have a small problem with NSTableView. When I am increasing height of a row in table, the text in it is aligned at top of row but I want to align it vertically centered!

4条回答
  •  隐瞒了意图╮
    2021-02-05 13:04

    Even if this is a very old question with an accepted answer, here's an alternate solution:

    Go into the IB, select your NSTextField sitting in a NSTableCellView and add a new "Center Vertically in Container" constraint. You should also add horizontal constraints (which should probably be leading/trailing space set to 0 or whatever suits your needs).

    Used this in an NSOutlineView and worked like a charm. Performance wasn't an issue in my case, as I didn't have many cells, but I would expect it's not worse than manually calculating sizes.

提交回复
热议问题