修改系统铃音音量

+ (void)setSystemVolumeTo:(float)newVolumeLevel {

Class avSystemControllerClass = NSClassFromString(@"AVSystemController");

id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];

NSString *soundCategory = @"Ringtone";

NSInvocation *volumeInvocation = [NSInvocation invocationWithMethodSignature: [avSystemControllerClass instanceMethodSignatureForSelector: @selector(setVolumeTo:forCategory:)]];

[volumeInvocation setTarget:avSystemControllerInstance];

[volumeInvocation setSelector:@selector(setVolumeTo:forCategory:)];

[volumeInvocation setArgument:&newVolumeLevel atIndex:2];

[volumeInvocation setArgument:&soundCategory atIndex:3];

[volumeInvocation invoke];

}

你可能感兴趣的:(修改系统铃音音量)