Transparent UIPopover

前端 未结 5 1317
野的像风
野的像风 2020-12-06 13:11

Is there a way to make the UIPopOver transparent (alpha = 0.75 or so). Unfortunately there is no alpha property for UIPopOver. I need to present a popover so that the view b

5条回答
  •  [愿得一人]
    2020-12-06 13:53

    For iOS 13:

    There seems to be an opaque subview with a dark gray background of type _UIPopoverStandardChromeView with no API means for controlling it (Apple bug?). To make the popover transparent, you may needed to the add the hack below to the presented view controller. It must be done in or after the viewDidAppear(_:) call. It didn't work in viewWillAppear(_:) or earlier calls.

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    
        // Only works in viewDidAppear()
        self.popoverPresentationController?.containerView?.subviews.last?.subviews.first?.alpha = 0
    }
    

提交回复
热议问题