[英]Adding a toolbar to INAppStoreWindow
我正在嘗試向INAppStoreWindow添加工具欄。
它有這個屬性:
/** The title bar view itself. Add subviews to this view that you want to show in
the title bar (e.g. buttons, a toolbar, etc.). This view can also be set if
you want to use a different styled title bar aside from the default one
(textured, etc.). **/
@property (nonatomic, retain) NSView *titleBarView;
我創建了一個工具欄,並鏈接到我的代碼中的插座,但如果它有一個NSToolbar類,當它需要NSView時,如何將其添加為子視圖?
拋出異常: [aWindow.titleBarView addSubview:toolbar];
提前謝謝了
INAppStoreWindow在窗口的小部件和內容視圖之間使用titleBarView
:
INAppStoreWindow.m:
- (void)setTitleBarView:(NSView *)newTitleBarView
{
if ((_titleBarView != newTitleBarView) && newTitleBarView) {
[_titleBarView removeFromSuperview];
[_titleBarView release];
_titleBarView = [newTitleBarView retain];
// Configure the view properties and add it as a subview of the theme frame
NSView *contentView = [self contentView];
NSView *themeFrame = [contentView superview];
NSView *firstSubview = [[themeFrame subviews] objectAtIndex:0];
[_titleBarView setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
[self _recalculateFrameForTitleBarView];
[themeFrame addSubview:_titleBarView positioned:NSWindowBelow relativeTo:firstSubview];
[self _layoutTrafficLightsAndContent];
[self display];
}
}
NSToolbar
不是NSView
子類,它意味着與窗口本身一起使用,它被titleBarView
。 只是為了踢,在INAppStoreWindow.m
設置漸變顏色的INAppStoreWindow.m
並運行app; 你可以看到“真正的”窗口仍在下面。
如果您已經開始使用INAppStoreWindow
,那么您最好的選擇可能是使用您自己的自定義視圖和按鈕偽造工具欄並將其添加為titleBarView
的子視圖。 當然,在這種情況下,你必須自己做所有的布局。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.