jonasalbert
12/20/2017 - 2:45 AM

Hide device volume while adjusting volume in a slider

1.
import MediaPlayer

2.
let volumeView = MPVolumeView(frame: CGRect.zero)

3.
  override func viewDidLoad() {
    super.viewDidLoad()
    
    volumeView.tag=1
    self.view.addSubview(volumeView)
    
  }
  
4.
  @IBAction func didTapCloseButton(_ sender: Any) {
    if let view = self.view.viewWithTag(1) {
      view.removeFromSuperview()
    }
    self.dismiss(animated: true, completion: nil)
  }