2
テーブルの列をサブクラス化してNStextFieldCell
にします。与えられたコードで列の色を変更したい場合、色は変わりません。どうして?サブクラス化した列の色を変更できません
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if(row%2==0)
[cell setBackgroundColor:[NSColor knobColor]];
else
[cell setBackgroundColor:[NSColor lightGrayColor]];
[cell setDrawsBackground: YES];
}
私は
- (NSRect)titleRectForBounds:(NSRect)theRect
{
NSRect titleFrame = [super titleRectForBounds:theRect];
NSSize titleSize = [[self attributedStringValue] size];
titleFrame.origin.y = theRect.origin.y + (theRect.size.height - titleSize.height)/2.0;
return titleFrame;
}
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect titleRect = [self titleRectForBounds:cellFrame];
[[self attributedStringValue] drawInRect:titleRect];
}
ないUIColorが、NSColor、。 –
'willDisplayCell'でそれを使用しています(実行時にエラーが発生すると、テーブルに行が表示されないことを意味します) –
どのようなエラーが発生しましたか?テーブルには何行ありますか?ログ/画面? – demon9733