我使用MPMusicPlayerController使用我的滑块更改系统音量:
-(void)viewDidLoad{
MPMusicPlayerController musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
}
然后我实现了以下方法来改变声音:
-(IBAction)sliderValueChanged:(UISlider *)sender{
[musicPlayer setVolume: sender.value];
}
- (void)volumeChanged:(NSNotification *)notification
{
float volume =[[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]floatValue];
[self.volumSeekbar setValue:musicPlayer.volume];
}
当我用导引头改变音量时,它显示了系统音量控制器,有什么方法可以阻止显示它吗?
答案 0 :(得分:2)
这些是我使用的图像 - 我只包括1x尺寸 - 拇指是54 x 30
[self.mpVolumeView setMinimumVolumeSliderImage:[UIImage imageNamed:@"master_volume_bar"] forState:UIControlStateNormal];
[self.mpVolumeView setMaximumVolumeSliderImage:[UIImage imageNamed:@"grey_volume_bar"] forState:UIControlStateNormal];
[self.mpVolumeView setVolumeThumbImage:[UIImage imageNamed:@"volume_thumb"] forState:UIControlStateNormal];