Skip to content

Instantly share code, notes, and snippets.

@laurenchen0631
Last active June 17, 2020 09:37
Show Gist options
  • Save laurenchen0631/d808f405de52d61f559b0e60a01d4426 to your computer and use it in GitHub Desktop.
Save laurenchen0631/d808f405de52d61f559b0e60a01d4426 to your computer and use it in GitHub Desktop.
Swiftui Canvas(Parent View)
import SwiftUI
struct CameraCanvas: UIViewRepresentable {
var backgroundColor: UIColor?
let rendererView = UIView()
func makeUIView(context _: Context) -> UIView {
rendererView.backgroundColor = backgroundColor ?? UIColor.black
return rendererView
}
func updateUIView(_: UIView, context _: Context) {}
}
struct CameraView_Previews: PreviewProvider {
static let canvas = CameraCanvas(backgroundColor: UIColor.white)
static var previews: some View {
canvas
.onAppear {
// operation that needs a parent view
// Drawer(view: canvas.rendererView)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment