2015-09-25 65 views
0

這裏有一個.swf(赦免,不良網站和SWF,這是我能捕捉到發生了什麼事的唯一途徑)繪製文本在NSSplitView分隔器上方,頂視圖偶爾會畫在它

http://screencast.com/t/rzJ3b5ihSj

看上去正在發生的事情是,我的分隔線有時會先畫出來,然後NSSplitView中的頂部NSView將其畫出。但似乎並不一致,因爲有時候分頻器會佔據上風。

這裏是我的-drawDividerInRect方法,從NSSplitView

-(void) drawDividerInRect:(NSRect)aRect 
{ 
    [[NSColor colorWithRed:10.0/255.0 green:10.0/255.0 blue:10.0/255.0 alpha:0.0] set]; 
    NSRectFill(aRect); 

    id topView = [[self subviews] objectAtIndex:0]; 
    NSRect topViewFrameRect = [topView frame]; 

    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Helvetica" size:26], NSFontAttributeName,[NSColor whiteColor], NSForegroundColorAttributeName, nil]; 

    NSAttributedString * currentText=[[NSAttributedString alloc] initWithString:@"Tool Properties" attributes: attributes]; 
    NSSize stringSize = [currentText size]; 

    CGFloat xOffset = ([topView frame].size.width - stringSize.width)/2; 
    NSRect textRect = NSMakeRect(topViewFrameRect.origin.x+xOffset, topViewFrameRect.size.height+50, stringSize.width, stringSize.height); 

    [currentText drawInRect:textRect]; 
} 

覆蓋我怎樣才能使它所以我在它分隔&文字繪製在上面所有的時間?

回答

0

所以實際上,分隔線和我想繪製的文字都是在NSSplitView上完成的。分隔線兩側的兩個視角都是子視角,所以在他們面前沒有辦法畫出來。我最終做的是在頂部視圖的底部添加一些填充,這樣分隔符文本總是被暴露出來