我的應用程序有一個使用InspectorBar一個NSTextView。然而,它只是坐在窗口這樣的頂部:可可:如何重新定位督察酒吧
我希望能夠將它定位更暗下來單槓,目前是NSImageView上。 setFrame似乎沒有效果。我怎樣才能做到這一點?
編輯:我目前正在修復別人的項目實施。正如您在下面看到的,他們能夠移動檢查器欄,並且它們不使用NSToolbar。所以它一定是可能的。
下面是這個人怎麼實現的是:
- (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];
}
但是,這並不在我的計劃有任何影響。
編輯2:如果我添加一個約束,像這樣:
[[self.leftColumnVC.textView.window.contentView superview] addConstraint:[NSLayoutConstraint constraintWithItem:inspectorBarView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:formattingBarBackground attribute:NSLayoutAttributeTop multiplier:1 constant:0 ]];
這裏formattingBarBackground是暗灰色條第一圖像中可見的上方。如果我這樣做,我得到這個:
這是好事,因爲有在頂部欄中沒有預留空間,並通過窗口的子視圖遍歷我仍然可以得到NSInspectorBar的引用,所以它仍然存在,它只是不可見。它隱藏在formattingBarBackground圖像視圖後面嗎?如果是這樣,我怎麼能把它帶到前面?
感謝您的回覆。請參閱我的編輯。 –
@JamesHarpe Yikes!這是*絕對*不支持;對不起,幫不了你。 :( –
我們最終選擇使用NSToolbar。謝謝! –