IOS15之音效播放
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
@property(nonatomic,assign)SystemSoundID soundID;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"diSound.wav" withExtension:nil];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &_soundID);
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
AudioServicesPlayAlertSound(_soundID);
}
@end
网友评论