How to customize MPVolumeView?

前端 未结 5 1603
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 23:48

I have tried many methods to implement a regular UISlider and control the device volume, but it\'s all Native-C functions which results in many untraceable bugs.

5条回答
  •  野的像风
    2021-01-31 00:14

    Answer in Swift:

    func customSlider() {
            let temp = mpVolView.subviews
            for current in temp {
                if current.isKind(of: UISlider.self) {
                    let tempSlider = current as! UISlider
                    tempSlider.minimumTrackTintColor = .yellow
                    tempSlider.maximumTrackTintColor = .blue
                }
            }
        }
    

    Result:

提交回复
热议问题