Home > Net >  How to use the area around Macbook's notch in fullscreen?
How to use the area around Macbook's notch in fullscreen?

Time:01-03

I need to use the area around (and behind) the notch while application is in full screen mode and display my app "fully full-screen" and use that area to display elements, as if there is no notch there.

I understand that is where the menu bar appears, but I am okay with either disabling menu bar in full screen OR making it act like older macs when it would appear over the application after we move cursor higher in that area.

I've tried (to no avail):

  • Playing with Safe Area
  • Hiding Title Bar from inspection menu in Xcode
  • Removing the Menu completely
  • Adding UISupportsTrueScreenSizeOnMac = true to plist

P.S. I've already done hours of searching on Google and SO, as well as Apple's documentation but haven't found any indication of how to achieve this.

CodePudding user response:

I do not think you can use fullscreen mode to do this, because there is no public API for overriding your window's fullscreen frame to include the unsafe areas around the sensor housing (the ‘notch’).

You should be able to manually achieve this by looking at the NSScreen representing the built-in display. Set your window's frame to the screen's frame (not the screen's visibleFrame). The screen's auxiliaryTopLeftArea and auxiliaryTopRightArea describe the areas to the left and right of the notch. From those, you can deduce the area obscured by the notch.

CodePudding user response:

This is how I managed to achieve this (simplified just for reference):

  1. Hide application's "Title Bar"
  2. Set your window's frame to full width and height on load (again, simplified)
override func windowDidLoad() {
    window!.setFrame(CGRect(x: 0, y: 0, width: NSScreen.main!.frame.width, height: NSScreen.main!.frame.height), display: true)
}
  1. Set LSUIPresentationMode in your plist
<key>LSUIPresentationMode</key>
<integer>3</integer> // Change this to 4 if you want to allow menu bar and dock to appear when user moves cursor top/bottom edges (they are initially hidden)

Note:

Without using LSUIPresentationMode or even hiding title bar, the following code would launch the app in fullscreen and for ~1 second it would fill the area around notch as well, but then it would revert back to the area below notch.

Just thought I should also mention this, so there might be ways to achieve this while using native fullscreen

window!.toggleFullScreen(self)
window!.setFrame(CGRect(x: 0, y: 0, width: 1728, height: 1117), display: true)
  • Related