I'm using MPVolumeView to show volume control in my app. I'd like to put right and left volume image to tell the meaning of the slider. (as it said on iOS Human Interface Guidelines).
Do I have to make two UIImageView on storyboard, create my own UIImage with photoshop and put them into the view or could I use a built-in method to do it?
edit:
Here it's what i'm doing. The UISlider appear and work, but not my speaker image. (I've put them into Images.xcassets)
_mpVolumeView.backgroundColor = [UIColor clearColor];
MPVolumeView * myVolumeView = [[MPVolumeView alloc] initWithFrame:_mpVolumeView.bounds];
[myVolumeView setMinimumVolumeSliderImage:[UIImage imageNamed:@"speakerMute"] forState:UIControlStateNormal];
[myVolumeView setMinimumVolumeSliderImage:[UIImage imageNamed:@"speakerMax"] forState:UIControlStateNormal];
[_mpVolumeView addSubview:myVolumeView];
The properties you're going to set are maximumValueImage
and minimumValueImage
both of which are UIImage
's.
From the docs:
The image you specify should fit within the bounding rectangle returned by the maximumValueImageRectForBounds: method. If it does not, the image is scaled to fit. In addition, the receiver’s track is lengthened or shortened as needed to accommodate the image in its bounding rectangle.
This default value of this property is nil.
Assuming you meet the size requirements writing yourSlider.minimumValueImage = [UIImage imageNamed:@"myImage.jpg"];
and then the same for the max value image is enough to get you going.