Last active
June 17, 2020 09:37
-
-
Save laurenchen0631/d808f405de52d61f559b0e60a01d4426 to your computer and use it in GitHub Desktop.
Swiftui Canvas(Parent View)
This file contains hidden or 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 | |
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