UIKit - Apple에서 제공되는 사운드 재생 방법
UIKit - Apple에서 제공되는 사운드 재생 방법
Apple에서 제공되는 사운드 재생 방법
AVFoundation을 통해 Apple에서 기본으로 제공해주는 사운드를 재생할 수 있음.
AVFoundation이란 Apple 플랫폼에서 오디오 재생, 캡처 등 다양한 기능을 쉽게 구현할 수 있도록 제공해주는 미디어 프레임워크임.
시스템 사운드를 재생하는 메서드
구현 예시 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
import UIKit
import AVFoundation // AVFoundation import
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func btnTapped(_ sender: UIButton) {
AudioServicesPlayAlertSound(SystemSoundID(1322)) // 사운드 재생
}
}
This post is licensed under CC BY 4.0 by the author.
