私は2つのViewController(ViewControllerとSettings)を持っています。スイッチをオフにしたときに、ボタンの音(またはアプリケーション内の音)がオフにされ、オンにされました。ボタンの音のためのボタンのオン/オフ音の設定
コード:
@IBAction func SoundButton(_ sender: UIButton) {
let filename = "button-16"
let ext = "mp3"
if let soundUrl = Bundle.main.url(forResource: filename, withExtension: ext) {
var soundId: SystemSoundID = 0
AudioServicesCreateSystemSoundID(soundUrl as CFURL, &soundId)
AudioServicesAddSystemSoundCompletion(soundId, nil, nil, { (soundId, clientData) -> Void in
AudioServicesDisposeSystemSoundID(soundId)
}, nil)
AudioServicesPlaySystemSound(soundId)
}
}
申し訳ありませんが管理するが、私は、質問を理解していないあなたは、より詳細に記述することができますか? –
@AnhPhamスイッチをオフにすると、ボタンの音がオフになる必要があります – KVL