I have tried many methods to implement a regular UISlider
and control the device volume, but it\'s all Native-C functions which results in many untraceable bugs. >
Since iOS 5.0 you can use UIAppearance on a UISlider, even when part of MPVolumeView.
Anywhere in your codebase:
[[UISlider appearanceWhenContainedIn:[MPVolumeView class], nil] setMinimumTrackImage:[[UIImage imageNamed:@"nowplaying_bar_full.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 25, 5, 25)] forState:UIControlStateNormal];
[[UISlider appearanceWhenContainedIn:[MPVolumeView class], nil] setMaximumTrackImage:[[UIImage imageNamed:@"nowplaying_bar_empty.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5, 25, 5, 25)] forState:UIControlStateNormal];
[[UISlider appearanceWhenContainedIn:[MPVolumeView class], nil] setThumbImage:[UIImage imageNamed:@"nowplaying_player_nob.png"] forState:UIControlStateNormal];
Here a list of some of the other classes that can be implemented using UIAppearance: https://gist.github.com/mattt/5135521