首先必须引入 AVFoundation
#import <AVFoundation/AVFoundation.h>
//震动反馈
if (@available(iOS 10.0, *)) {
UIImpactFeedbackGenerator*impactLight = [[UIImpactFeedbackGenerator alloc]initWithStyle:UIImpactFeedbackStyleLight];
[impactLight impactOccurred];
} else {
// Fallback on earlier versions
}
// 铃声
AudioServicesPlaySystemSound(1000);
// 震动
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
CF_ENUM(SystemSoundID)
{
kSystemSoundID_UserPreferredAlert = 0x00001000,
kSystemSoundID_FlashScreen = 0x00000FFE,
// this has been renamed to be consistent
kUserPreferredAlert = kSystemSoundID_UserPreferredAlert
};
CF_ENUM(SystemSoundID)
{
kSystemSoundID_Vibrate = 0x00000FFF
};