验证中...
Languages: Objective-C
Categories: iOS 组件
Latest update 2019-04-02 15:31
gistfile1.txt
Raw Copy
- (UISlider *)getAudioVolumeSlider {
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(-1000, -1000, 100, 4)];
[self.window addSubview:volumeView];
UISlider *volumeSlider = nil;
for (UIView *item in [volumeView subviews]) {
if ([[item.class description] isEqualToString:@"MPVolumeSlider"]) {
volumeSlider = (UISlider *)item;
break;
}
}
return volumeSlider;
}
- (void)audioVolumeMax {
UISlider *volumeSlider = [self getAudioVolumeSlider];
if (volumeSlider) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[MyDefaults setFloat:volumeSlider.value forKey:@"kVolumeValue"];
float value = 1.0;
[volumeSlider setValue:value animated:NO];
// [volumeSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[volumeSlider.superview removeFromSuperview];
});
});
}
}
- (void)audioVolumeRestore {
UISlider *volumeSlider = [self getAudioVolumeSlider];
if (volumeSlider) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
float value = [MyDefaults floatForKey:@"kVolumeValue"];
[volumeSlider setValue:value animated:NO];
// [volumeSlider sendActionsForControlEvents:UIControlEventTouchUpInside];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[volumeSlider.superview removeFromSuperview];
});
});
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search