【发布时间】:2017-09-24 05:40:08
【问题描述】:
有没有办法像苹果计算器应用一样使用系统声音
@IBAction func button(_ sender: UIButton) {
}
感谢帮助
相信有一些不同我的意思是使用系统声音 发布的问题是专注于使用 url 声音
【问题讨论】:
有没有办法像苹果计算器应用一样使用系统声音
@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来查看其他常量。
【讨论】:
kSystemSoundID_Vibrate 只是一个常数。