有没有办法将NSWindow创建为全屏模式? NSWindow有ToggleFullscreen:选择器,但它会正常创建窗口并将其动画为全屏版本,这不是我想要的。这样做的其他方式是什么?
答案 0 :(得分:4)
首先找到屏幕尺寸
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
{
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
}
screenRect
包含屏幕大小,不创建窗口并将NSWindow
大小设置为屏幕大小。
unsigned int styleMask = NSTitledWindowMask
| NSMiniaturizableWindowMask;
myWindow = [NSWindow alloc];
myWindow = [myWindow initWithContentRect: screenRect
styleMask: styleMask
backing: NSBackingStoreBuffered
defer: NO];
[myWindow setTitle: @"This is a test window"];
答案 1 :(得分:3)
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSRect frame=[NSScreen mainScreen].frame ;
[self.window setFrame:frame display:YES animate:YES];
}
这将全屏打开窗口