2011-12-13 7 views
0

tableview의 헤더에 그래디언트를 채우려고합니다. 지금까지 나는 그것이 this-NSTableHeaderView의 채우기 그래디언트가 제대로 작동하지 않습니다.

처럼 나타나고있다가 이제 this-

enter image description here

처럼 나타나는 그래서 이전 NSTableHeaderView를 서브 클래스와 - 그것을

- (void)drawRect:(NSRect)dirtyRect { 
    // Drawing code here. 

    NSGradient *gradientToFill = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedRed:0.8828125 green:0.8984375 blue:0.91015625 alpha:1.0] 
                   endingColor:[NSColor colorWithCalibratedRed:0.5546875 green:0.59765625 blue:0.66015625 alpha:1.0] ]; 
    [gradientToFill drawInRect:dirtyRect angle:90]; 
} 

이 코드를 사용하여 그것을 달성 할 수 있어요 이 코드는 내가 몇 proble 직면 사용하는 경우, 위의 스크린 샷과 같이

enter image description here

ms :

  1. 열 머리글 제목이 표시되지 않습니다.
  2. 헤더 열 구분 기호가 표시되지 않습니다.

아무에게도이 문제를 해결하는 방법이나 더 좋은 방법을 구현할 수 있습니까?

답변

1

NSTableHeaderCell을 사용자 지정하고 그라디언트를 NSCell's 그리기 방법으로 채워야합니다. 다음 방법을 구현해야합니다.

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

-(void)highlight:(BOOL)isHighlighted withFrame:(NSRect)cellFrame inView:(NSView *)view

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;