Search code examples
avplayeravplayerviewcontrolleravplayeritem

How to Hide/remove maximise button from AVPlayer/AVPlayer view controller


When we implemented avplayer and we dont need one of the avplayer controller i.e maximise button, So unable to hide that button.

I tried to hide maximise button using hide all controlls but individually not possible to hide.


Solution

  • We can hide the maximize button from getting subviews from AVPlayerViewController. In Subviews need to find the AVMobileChromelessDisplayModeControlsView class object and hide that view.

    if let orientaion = playerVC.view.subviews.first?.subviews.last?.subviews.first    {
            orientaion.isHidden = true
        }