Panda Panda - 1 year ago 142
iOS Question

how to set the maximum and minimum image of MPVolumeView correctly

i am trying to set the maximum and minimum image of MPVolumeView but i can't get it working

here is the code

VolumeView.setVolumeThumbImage(UIImage(named: "VolumeSlider"), forState: UIControlState.Normal)
VolumeView.setMinimumVolumeSliderImage(UIImage(named: "VolumeUp"), forState: UIControlState.Normal)
VolumeView.setMaximumVolumeSliderImage(UIImage(named: "VolumeDown"), forState: UIControlState.Normal)

and here is the result

does any one had this problem before , any help will be great ?

Answer Source

The code you have written is fine, however, you misunderstood what setMinimumVolumeSliderImage and setMaximumVolumeSliderImage achieve. These methods are for actually setting the track images of the control.

You're looking for something comparable to minimumValueImage and maximumValueImage on UISlider. Unfortunately, MPVolumeView doesn't have such methods.

The only work around would be to position a UIImageView either side of the volume view to show your images. The downside to this is that the route button will get in the way for the maximum value image, so you would have to set showsRouteButton = NO; to prevent this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download