在停靠栏和菜单之间设置 OSX 个应用程序框架
Set OSX application frame between dock and menu
我是Objective-c的新手,我不知道如何设置菜单栏和Dock之间的框架高度。我查了很多关于它的问题,这是我的代码:
我创建了一个名为 MainWindowController
的 NSWindowController
文件。
MainWindowController.m
#import "MainWindowController.h"
@interface MainWindowController ()
@end
@implementation MainWindowController
- (void)windowDidLoad {
[super windowDidLoad];
int screenWidth = [NSScreen mainScreen].frame.size.width;
int screenHeight = [NSScreen mainScreen].frame.size.height;
[self.window setFrame:NSMakeRect(0, 0, screenWidth, screenHeight) display:YES];
[self.window setContentSize:NSMakeSize(screenWidth, screenHeight)];
[self.window setContentMaxSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setContentMinSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setMaxFullScreenContentSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setMinFullScreenContentSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window toggleFullScreen:self];
// Set Title Bar
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSWindowStyleMaskFullSizeContentView;
}
@end
但结果是这样的:
enter image description here
如何设置超出停靠栏的框架?
屏幕尺寸使用-[NSScreen frame]
on an instance received through e.g. +[NSScreen mainScreen]
or -[NSWindow screen]
。
要获得没有停靠栏和菜单栏的可见部分,请使用 -[NSScreen visibleFrame]
。
请记住,整个桌面可以跨越多个屏幕。
我是Objective-c的新手,我不知道如何设置菜单栏和Dock之间的框架高度。我查了很多关于它的问题,这是我的代码:
我创建了一个名为 MainWindowController
的 NSWindowController
文件。
MainWindowController.m
#import "MainWindowController.h"
@interface MainWindowController ()
@end
@implementation MainWindowController
- (void)windowDidLoad {
[super windowDidLoad];
int screenWidth = [NSScreen mainScreen].frame.size.width;
int screenHeight = [NSScreen mainScreen].frame.size.height;
[self.window setFrame:NSMakeRect(0, 0, screenWidth, screenHeight) display:YES];
[self.window setContentSize:NSMakeSize(screenWidth, screenHeight)];
[self.window setContentMaxSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setContentMinSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setMaxFullScreenContentSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window setMinFullScreenContentSize:NSMakeSize(screenWidth, screenHeight - self.window.dockTile.size.height)];
[self.window toggleFullScreen:self];
// Set Title Bar
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSWindowStyleMaskFullSizeContentView;
}
@end
但结果是这样的: enter image description here
如何设置超出停靠栏的框架?
屏幕尺寸使用-[NSScreen frame]
on an instance received through e.g. +[NSScreen mainScreen]
or -[NSWindow screen]
。
要获得没有停靠栏和菜单栏的可见部分,请使用 -[NSScreen visibleFrame]
。
请记住,整个桌面可以跨越多个屏幕。