Created
June 29, 2024 17:34
-
-
Save alexklyuev/5ab995ac6f5fdd5c7f343b0843d4deb6 to your computer and use it in GitHub Desktop.
Use SwiftUI view as ExpoView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import ExpoModulesCore | |
class ModuleContainerView: ExpoView { | |
var hostingController: UIHostingController<some View> = UIHostingController(rootView: ModuleContentView()) | |
required public init(appContext: AppContext? = nil) { | |
super.init(appContext: appContext) | |
hostingController.view.backgroundColor = .clear | |
hostingController.view.frame = self.bounds | |
hostingController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
addSubview(hostingController.view) | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment