iOS 11 negative additionalSafeAreaInsets?

Viewed 1975

I'm trying to cope with the wasted space on iPhone x in landscape mode by using this little trick:

func fixSafeArea() {
    guard #available(iOS 11, *) else {
        print("Safe area is not available for non iOS 11 devices.")
        return
    }

    var newSafeArea = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

    if UIDevice.current.orientation == .landscapeRight {
        newSafeArea.left = -20.0
    } else if UIDevice.current.orientation == .landscapeLeft {
        newSafeArea.right = -20.0
    }

    print("Safe area adjusted to \(newSafeArea)")
    self.additionalSafeAreaInsets = newSafeArea
}

However negative UIEdgeInsets do not seem to work. Does anyone know how to override the safeArea insets in order to make use of the free screen on wither landscape orientations?

And one more thing: Why didn't apple make this the default behaviour since they put the home "slider" at the bottom? The screen on the opposite side of the top notch is literally wasted using safe areas in landscape

0 Answers
Related