我想在我的 SwiftUI 应用程序中按下按钮时添加声音效果。该按钮还有一个功能,但我只想添加一个声音效果。我已经使用 UIkit 找到了先前版本的 Xcode 的信息,但我不明白如何在 SwiftUI 中执行此操作。
编辑:如果这解释了我缺乏知识,我对编程很陌生。
from answer: Play reminder sound SwiftUI
you can use this simple method:
import AVFoundation
AudioServicesPlaySystemSound(1026)
Run Code Online (Sandbox Code Playgroud)
where the number 1026 is the SystemSound id.
| 归档时间: |
|
| 查看次数: |
1186 次 |
| 最近记录: |