How do you implement an MPVolumeView?

后端 未结 3 1113
刺人心
刺人心 2021-01-04 23:51

I want the user to be able to change the system volume with a slider, and I realized the only way to do this is with an MPVolumeView.

But I can\'t find any example c

3条回答
  •  囚心锁ツ
    2021-01-05 00:13

    Place it as a generic UIView, then use the inspector to set the class to MPVolumeView (ensuring that you also link the MediaPlayer framework). It'll still be shown as a regular slider in IB, but at runtime, it will be an instance of MPVolumeView and will have the necessary styles and behavior. Note that this may not work as expected in the iOS Simulator, which doesn't permit volume control.

提交回复
热议问题