iOS版:增加系统声音按钮,迅速
问题描述:
有没有使用系统的声音,如苹果的计算器应用程序的方式iOS版:增加系统声音按钮,迅速
@IBAction func button(_ sender: UIButton) {
}
帮助表示赞赏
相信有一些不同的仅仅是用系统的声音 张贴的问题是专注于使用url声音
答
您可以使用AudioToolbox框架。用法示例(使设备振动):
import AudioToolbox.AudioServices
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
完整的文档:https://developer.apple.com/documentation/audiotoolbox
要尝试另一个常量,看到这一点:https://developer.apple.com/documentation/audiotoolbox/system_sound_services/1618202-alert_sound_identifiers
或只是命令+点击不变kSystemSoundID_Vibrate
看其他常量。
谢谢....你能给我另一个例子不振动,但播放系统声音...我与SystemSoundID – jin
看到我的编辑。基本上,'kSystemSoundID_Vibrate'只是一个常量。 – Glenn
但仅适用于iPhone的kSystemSoundID_Vibrate。 – jin