uiviewcontroller - MacCatalyst Scene Frame needs adjustment - Stack Overflow

admin2025-04-30  0

I don't know why, but for my MacCatalyst target, I have to make my view controller Y orgin 36 and the subtract the view height by 36 points, or the view is clipped.

The following works in my main UIViewController, but feels super hacky. I'd feel better if I understood the issue and addressed it properly.

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    #if targetEnvironment(macCatalyst)
    if view.frame.origin.y < 1 {
        let f = UIApplication.shared.sceneBounds
        let newFrame = CGRect(x: 0.0, y: 36, width: f.size.width, height: f.size.height - 36)
        self.view.frame = newFrame
    }
    #endif
}

My guess is it starts the view under the title bar, but I have these set in the view controller:

self.extendedLayoutIncludesOpaqueBars = false
self.edgesForExtendedLayout = []
转载请注明原文地址:http://anycun.com/QandA/1746023907a91490.html