Reputation: 43
I would like to add a sound effect when a button is pressed in my app for SwiftUI. The button has another feature, but I just want to add a sound effect. I have found information for previous versions of Xcode using UIkit, but I'm not understanding how to do it in SwiftUI.
Edit: I'm very new to programming if that explains my lack of knowledge.
Upvotes: 4
Views: 7937
Reputation: 37075
from answer: Play reminder sound SwiftUI
you can use this simple method:
import AVFoundation
AudioServicesPlaySystemSound(1026)
where the number 1026 is the SystemSound id.
Upvotes: 14