0
我正在開發一個使用全屏窗口的簡單應用程序。可可應用程序進入全屏幕
窗口包含視圖包含按鈕,圖像等等...,但是當我在全屏幕與後續的行中輸入:
NSWindow* tmp = [self window];
[tmp setStyleMask:NSBorderlessWindowMask];
[tmp setFrame:[tmp frameRectForContentRect:[[tmp screen] frame]]display:YES animate:NO];
[tmp setBackingType:NSBackingStoreBuffered];
screenRect = [[NSScreen mainScreen] frame];
int windowLevel = CGShieldingWindowLevel();
[self.window setLevel:windowLevel];
我把窗口視圖不自動調整大小,我可以做一些正確調整大小的操作,但有一種方法可以自動執行該操作?
我後我所有的AppController這裏:
-(id)init {
self = [super initWithWindowNibName:@"MainWindow"];
NSWindow* tmp = [self window];
[tmp setStyleMask:NSBorderlessWindowMask];
[tmp setFrame:[tmp frameRectForContentRect:[[tmp screen] frame]]display:YES animate:NO];
[tmp setBackingType:NSBackingStoreBuffered];
screenRect = [[NSScreen mainScreen] frame];
/**
// [[tmp standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
// [[tmp standardWindowButton:NSWindowZoomButton] setHidden:YES];
self.window = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]];
**/
int windowLevel = CGShieldingWindowLevel();
[self.window setLevel:windowLevel];
return self;
}
// We need to be layer-backed to have subview transitions.
-(void)awakeFromNib {
[[self window] setContentSize:[topMenu frame].size];
[[[self window] contentView] addSubview:topMenu];
[topMenu enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
[[[self window] contentView] setWantsLayer:YES];
}
- (void)dealloc
{
[super dealloc];
}
- (void)windowDidLoad
{
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[topMenu_controller performAnimation];
return;
}
的聯繫是過時的,我必須搜索佈局? – pedr0 2011-03-10 08:44:50
您需要爲視圖設置尺寸屬性,以便它保持與窗口相同的比例。在界面生成器中選擇視圖,然後選擇工具→顯示檢查器,然後從檢查器窗口頂部的下拉列表中選擇大小。檢查器窗口的下半部分包含標有「自動調整」的部分。這些被稱爲「彈簧和支柱」。 單擊內部框中的水平線和垂直線,以便它們變成彈簧。這會導致文本視圖的內部大小隨着窗口的增長而縮小。 – 2011-03-10 17:44:18
[Here's](https://web.archive.org/web/20100901161944/http://developer.apple.com:80/mac/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html)an該文檔的歸檔版本和[這裏是](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/index.html#//apple_ref/doc/uid/TP40010853-CH7-SW1 )一些文件解釋蘋果新的佈局引擎,自動佈局。 – NobodyNada 2017-05-11 23:43:36