美文网首页
如何自定义音量调节条

如何自定义音量调节条

作者: Codepgq | 来源:发表于2020-04-02 17:37 被阅读0次

    记录

    在VC中新增如下代码

     // Add MPVolumeView in a holder view
            let mpVolumeHolderView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height))
             // Set the holder view’s background color to transparent
             mpVolumeHolderView.backgroundColor = .clear
            let mpVolume = MPVolumeView(frame: mpVolumeHolderView.bounds)
            mpVolume.showsRouteButton = true
            mpVolumeHolderView.addSubview(mpVolume)
            view.addSubview(mpVolumeHolderView)
            // the volume view is white, set the parent background to black to show it better in this example
            view.backgroundColor = .black
    

    如果要隐藏,就加入一个延时
    伪代码

    ....setVolume(1, animate: false)
    

    相关文章

      网友评论

          本文标题:如何自定义音量调节条

          本文链接:https://www.haomeiwen.com/subject/euxfphtx.html