Мое решение здесь, но мне интересно, есть какой-то лучший метод.
import SwiftUI
class HostVC<T>: UIHostingController<T> where T: View {
override var shouldAutorotate: Bool {ContentView.autoRotate}
}
struct ContentView: View {
static var autoRotate: Bool = false
var body: some View {
Button("Rotate") {
let r: Int
switch UIDevice.current.value(forKey: HomeView.keyOrientation) {
case let i as Int where i == UIInterfaceOrientation.landscapeRight.rawValue: r = UIInterfaceOrientation.landscapeLeft.rawValue
default: r = UIInterfaceOrientation.landscapeRight.rawValue
}
ContentView.autoRotate = true
UIDevice.current.setValue(r, forKey: HomeView.keyOrientation)
ContentView.autoRotate = false
}
}
}