My app has an NSTextView that uses the InspectorBar. However, it just sits at the top of the window like this:
I want to be able to position it further down on the dark horizontal bar, which currently is an NSImageView. setFrame seems to have no effect. How can I do this?
EDIT: I'm currently working on fixing someone else's implementation of a project. As you can see below, they were able to move the inspector bar, and they are not using NSToolbar. So it must be possible.
Here's how this person achieved this:
- (void) addStyleBar
{
NSArray* subviews = [self.window.contentView superview].subviews;
[self.styleBar removeFromSuperview];
[subviews enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop)
{
if (![obj isKindOfClass: [MainView class]])
{
self.styleBar = obj;
}
}];
[self.styleBar setFrame: NSMakeRect(300.0f, 2.0f, CGRectGetWidth(self.styleBar.frame), CGRectGetHeight(self.bounds))];
[self addSubview: self.styleBar];
}
But this doesn't have any effect in my project.
EDIT 2: If I add a constraint like so:
[[self.leftColumnVC.textView.window.contentView superview] addConstraint:[NSLayoutConstraint constraintWithItem:inspectorBarView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:formattingBarBackground attribute:NSLayoutAttributeTop multiplier:1 constant:0 ]];
Here formattingBarBackground is that dark gray bar seen in the first image above. If I do this I get this:
This is good because there is no reserved space for the bar at the top, and by iterating through the window's subviews I can still get a reference to NSInspectorBar, so it's still there, it's just not visible. Is it hiding behind the formattingBarBackground image view? If so how can I bring it to the front?