Search code examples
uikitavplayerviewcontroller

Removing UIVisualEffect from AVPlayerViewController.customoverlayViewController


I am implementing AVPlayerViewController.customOverlayViewController and I was wondering if there is a way to remove the UIVisualEffect and apply a clear background on the presentation. I am attaching a screenshot with the view Hirechay.

enter image description here


Solution

  • According to the view hierarchy, the ChannelViewController is part of the AVxCustomOverlayHostViewController, and its view of type AVxHostView includes the UIVisualEffectView. So:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // Remove UIVisualEffectView
        if let parent = parent {
            parent.view.subviews.filter({ $0 is UIVisualEffectView }).forEach({ $0.alpha = 0 })
        }
    }
    

    If you want you can also remove it.