0

Here's a .swf (pardon, the bad website and swf, that was the only way I could capture what was happening)

http://screencast.com/t/rzJ3b5ihSj

What appears to be happening, is that my divider is occasionally drawn first, and then the top NSView in the NSSplitView draws over it. But it seems inconsistent, because sometimes the divider draws on top.

Here is my -drawDividerInRect method, overridden from 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];
}

How can I make it so my divider & text within it draws on top all the time?

A O
  • 5,516
  • 3
  • 33
  • 68

1 Answers1

0

So actually the divider, and the text I wanted to draw, were all being done on the NSSplitView itself. The two views on either side of the divider are subviews, and so there's no way to draw in front of them. What I ended up doing was add some padding at the bottom of the top view so that the divider text is always exposed

A O
  • 5,516
  • 3
  • 33
  • 68