Unable to change NSTableHeaderCell font on El Capitan

时间:2016-04-15 14:45:31

标签: cocoa nstableview osx-elcapitan nscell nstablecolumn

I'm developing a Cocoa App (OSX) and, in my tableview, I want to change the font of all of my columns.

I'm using the cell-based version.

Strangely, It is not possible to do it by using Interface Builder (IB). Each time, it forces me to use the font "System Small" !

But, if I activate the "hidden" checkbox, It allows me to change the font! So stupid!

So in my code (a derived class of NSTableView) I change the font of all my columns like that :

[ self.tableColumns forEachWithIndex:^( NSTableColumn * tableColumn, NSUInteger index, BOOL * stop )   {
    ...
    NSTableHeaderCell * tableHeaderCell = [ [ NSTableHeaderCell alloc ] initTextCell:@"TEST" ];
tableHeaderCell.font = [ NSFont boldSystemFontOfSize:16 ];

[ tableColumn setHeaderCell:tableHeaderCell ];

But, the font is always the small font on OSX El Capitan 10.11.4 : Result on El Capitan

Whereas, the same code in Yosemite displays the correct font :

Result on Yosemite

I don't understand why?

Is there a specific thing to do in El Capitan with NSCell?

Thanks for any help.

0 个答案:

没有答案