Popover transparency issue only for iPhone 11 and Max versions

Viewed 36

I am facing a weird issue. There is an UIPopoverPresentationController and I have this situation: It is working fine on Portrait, but on Landscape, I lose the background and the layout. AND it is happening only for iPhone 11 and Max version, it is fine for iPhone X, 11 pro, 12, etc.

Obs: If I set the popover background color, it works with the new color, but why the background is transparent only on these versions above with the layout different?

I did a POC with a simple code to reproduce the problem:

ViewController

@IBAction func showPopover(sender: AnyObject) {
        
        let popVC = PopoverViewController.init()
        popVC.modalPresentationStyle = .popover

        let popOverVC = popVC.popoverPresentationController
        popOverVC?.delegate = self
        popOverVC?.sourceView = view
        popOverVC?.sourceRect = sender.frame
        popVC.preferredContentSize = CGSize(width: 250, height: 250)

        self.present(popVC, animated: true)
    }

PopoverViewController

override func viewDidLoad() {
        let view2 = UIView.init()
        let view3 = UIView.init()
        
        view2.backgroundColor = .blue
        view2.alpha = 0.5
        view3.backgroundColor = .blue
        view3.alpha = 0.5
        view.addSubview(view2)
        view.addSubview(view3)
        
        view2.translatesAutoresizingMaskIntoConstraints = false
        view2.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 5).isActive = true
        view2.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -5).isActive = true
        view2.topAnchor.constraint(equalTo: view.topAnchor, constant: 25).isActive = true
        view2.heightAnchor.constraint(equalToConstant: 30).isActive = true
        
        view3.translatesAutoresizingMaskIntoConstraints = false
        view3.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 5).isActive = true
        view3.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -5).isActive = true
        view3.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -25).isActive = true
        view3.heightAnchor.constraint(equalToConstant: 30).isActive = true
    }
    
    public func getPopover(sourceView: UIView) {
        modalPresentationStyle = .popover
        let popoverPresentation = self.popoverPresentationController
        popoverPresentation?.sourceView = sourceView
        popoverPresentation?.sourceRect = sourceView.bounds
    }
0 Answers
Related