특정 방향으로 UI를 표시해야 하는 시나리오가 가로 또는 세로일 수 있습니다.
iOS에서 Swift를 사용하여 프로그래밍 방식으로 방향을 잠그는 방법을 살펴보겠습니다.
Xcode 열기 → New Project → ViewController.swift 아래 코드를 작성하세요.
// Set the shouldAutorotate to False
override open var shouldAutorotate: Bool {
return false
}
// Specify the orientation.
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
