saltfactory's blog

Database, Web, Mobile, Client, Programming Languages

분류 전체보기 (188)
Freeboard (13)
Algorithms (0)
Appspresso (21)
Sencha (13)
Mac (11)
iOS (37)
Android (10)
Web (5)
Javascript (8)
Unix/Linux (12)
Ruby (16)
Java (11)
Python (4)
PHP (9)
Database (18)
  • 302,542
  • 591
  • 557

NSCell을 상속받아서 만든 Cell을 선택하였을 때 글자 색상 흰색으로 변경

2011/02/08 10:51

NSCell을 상속받아 만든 Cell에서 Cell 선택시 하이라이트 되어지는 곳의 글자 색상이 검은색이면 시각적으로 보기 좋지 않아서 draw될때 선택된 cell이면 글자 색상을 하얀색으로 변경하고 싶을 때 아래와 같이 하면 된다.



- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

{

NSColor *textColor;

NSPoint textPoint;

NSString *bannerTitle;

NSMutableDictionary *textAttributes;

if([self isHighlighted]) {

textColor = [NSColor selectedMenuItemTextColor];

} else {

textColor = [NSColor controlTextColor];

}

if ([[self objectValue] isKindOfClass:[NSString class]]) {

bannerTitle = [self objectValue];

textPoint.x = cellFrame.origin.x + 10;

textPoint.y = cellFrame.origin.y + 12;

textAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys: textColor, 

  NSForegroundColorAttributeName, [NSFont systemFontOfSize:14], NSFontAttributeName, nil];

[bannerTitle drawAtPoint:textPoint withAttributes:textAttributes];

}

저작자 표시 비영리 동일 조건 변경 허락

saltfactory