Panda Panda - 4 months ago 60
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 ?


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.