Skip to content

Instantly share code, notes, and snippets.

@iamidzic
Created March 11, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamidzic/9874a63a7d15ddbc18b8795f48a886f7 to your computer and use it in GitHub Desktop.
Save iamidzic/9874a63a7d15ddbc18b8795f48a886f7 to your computer and use it in GitHub Desktop.
SettingsChildView
private func addSettingsView() {
let settingsView = SettingsView()
let hostingController = UIHostingController(rootView: settingsView)
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
hostingController.didMove(toParent: self)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment