За это отвечает функция setupExternalWindow.
ExternalDisplayManager.swift:
private func setupExternalWindow(for screen: UIScreen) {
removeExternalWindow()
guard let mode = screen.currentMode else {
print("
return
}
let nativeSize = mode.size
let scale = screen.nativeScale
let logicalSize = CGSize(width: nativeSize.width / scale,
height: nativeSize.height / scale)
print("""
- Native pixel size: \(nativeSize)
- Logical size: \(logicalSize)
- Scale: \(scale)
""")
let window = UIWindow(frame: screen.coordinateSpace.bounds)
window.screen = screen
window.backgroundColor = .black
window.isHidden = true
window.contentScaleFactor = scale
let desktop = DesktopModelHolder.shared.desktopModel
let cursor = CursorManager.shared
let externalRoot = ExternalDesktopView()
.environmentObject(desktop)
.environmentObject(cursor)
.ignoresSafeArea()
.frame(width: logicalSize.width, height: logicalSize.height)
.clipped()
let host = UIHostingController(rootView: AnyView(externalRoot))
host.view.backgroundColor = .black
host.view.frame = window.bounds
host.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
host.view.contentScaleFactor = scale
host.view.layer.contentsScale = scale
host.view.transform = .identity
host.additionalSafeAreaInsets = .zero
host.view.layer.masksToBounds = true
host.modalPresentationStyle = .fullScreen
window.rootViewController = host
DispatchQueue.main.async {
self.externalWindow = window
self.externalHostingController = host
window.isHidden = false
window.makeKeyAndVisible()
host.view.layoutIfNeeded()
CATransaction.flush()
self.isExternalConnected = true
print("External display is now rendered in TRUE FULLSCREEN.")
}
updateExternalPointer(from: cursor.mainPointerLocation)
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -both-ipho
Мобильная версия