首先必須引入 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
};