Example when you double-click Xcode's toolbar, Xcode will automatically goes full screen (still show's menubar). How I can achieve same result programmatically using storyboards and Xcode 7 GM?
This mode is not called "full screen" but "zoomed".
You can "zoom" a window to the max available space by using the NSScreen visible frame as the target frame.
Let's say window
is your NSWindow IBOutlet:
window.setFrame(NSScreen.mainScreen()!.visibleFrame, display: true, animate: true)
在目标 C 中:
[self.window setFrame:NSScreen.mainScreen.visibleFrame display: true animate: true];
Here is the swift 5 version. In viewWillAppear()<\/strong> function of you view controller, call this function.
func setWindowFrameAndCenter() {
guard let window = self.view.window,
let windowScreenFrame = window.screen?.visibleFrame else {
return
}
window.setFrame(windowScreenFrame,
display: false,
animate: false)
window.center()
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.