iOS 获取系统音量

//设置一个全局变量
UISilder * volumeViewSlider;

#pragma mark - 获取系统音量
- (void)configureVolume
{
    volumeView = [[MPVolumeView alloc]init];
    volumeView.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);
    [volumeView sizeToFit];
    volumeView.showsVolumeSlider = NO;
    [self addSubview:volumeView];
    [volumeView userActivity];
    for (UIView *view in [volumeView subviews]){
        if ([[view.class description] isEqualToString:@"MPVolumeSlider"]){
            volumeViewSlider = (UISlider*)view;
            break;
        }
    }
}

调节音量

volumeViewSlider.value +=0.01;

 

posted @ 2016-04-15 10:16  友朋  阅读(1651)  评论(0编辑  收藏  举报