Skip to content

Instantly share code, notes, and snippets.

@igorzhukov
Last active February 22, 2023 11:34
Show Gist options
  • Save igorzhukov/4b7e88f9a70a7780e8863191158ca1c7 to your computer and use it in GitHub Desktop.
Save igorzhukov/4b7e88f9a70a7780e8863191158ca1c7 to your computer and use it in GitHub Desktop.
Wrapper for embedding UIKit UIView in SwiftUI
import Foundation
import SwiftUI
struct UIKitWrapper<Type: UIView>: UIViewRepresentable {
let configuration: ((Type) -> Void)
func makeUIView(context: UIViewRepresentableContext<Self>) -> Type {
return Type()
}
func updateUIView(_ uiView: Type, context: UIViewRepresentableContext<Self>) {
configuration(uiView)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment