Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to customize MPVolumeView?
    primarykey
    data
    text
    <p>I have tried many methods to implement a regular <code>UISlider</code> and control the device volume, but it's all Native-C functions which results in many untraceable bugs. </p> <p>I tried the <code>MPVolumeView</code> it works like charm, it even controls the device volume even after you close the app, just like the iPod app.</p> <p>My question is, is there anyway to customize the <code>MPVolumeView</code> with specific colors and images, just like <code>UISlider</code>?</p> <p>NOTE: I want a legal method without using private undocumented APIs.</p> <p><strong>UPDATE</strong><br> As per @Alexsander Akers answer, since the sub views are hidden in <code>MPVolumeView</code> I had to cycle through subviews, get the <code>UISlider</code> and customize it, here is the code.</p> <pre><code>IBOutlet UISlider *volumeSlider; //defined in &lt;class.h&gt; and connected to a UISlider in Interface Builder -(void) viewDidLoad { .... [self setCustomSlider]; .... } -(void) setCustomSlider{ MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:[volumeSlider frame]] autorelease]; NSArray *tempArray = volumeView.subviews; for (id current in tempArray){ if ([current isKindOfClass:[UISlider class]]){ UISlider *tempSlider = (UISlider *) current; UIImage *img = [UIImage imageNamed:@"trackImage.png"]; img = [img stretchableImageWithLeftCapWidth:5.0 topCapHeight:0]; [tempSlider setMinimumTrackImage:img forState:UIControlStateNormal]; [tempSlider setThumbImage:[UIImage imageNamed:@"thumbImage.png"] forState:UIControlStateNormal]; } } [volumeSlider removeFromSuperview]; [self.view addSubview:volumeView]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload