Ha
hankyeol
Sign In
한결
Sep 2, 2024
Sep 2, 2024
Status
Empty
Assignee
Empty
UIKit 프로젝트에서 SwiftUI 코드로 작성한 화면을 띄우는 방법
•
iOS13+ 버전에서 활용할 수 있는
UIHostingController
를 통해서 some View를 반환하는 구조체 인스턴스를 넣어준다.
•
UIHostingController는 기본적으로 UIViewController를 상속받고, View 프로토콜을 따르는 객체를 반환하는 인스턴스를 제네릭 타입으로 가진다.
let vc = UIHostingController(rootView: ContentView1()) present(vc, animated: true)