Reputation: 25
I have a blue Rectangle overlaying a camera preview layer inside of a ZStack.
What I want to do is cut a RoundedRectangle "frame" out of the blue Rectangle so the camera preview layer has a blue framing with rounded corners.
How do I cut out a RoundedRectangle from the Blue Rectangle to reveal the preview layer below? Is there a way to invert the clip-shape??
Below is a picture of what I currently have, the black color represents the camera preview layer which is currently hidden by the blue Rectangle.
struct CameraView: View {
var body: some View {
ZStack { // can I invert this clipshape to reveal camera view??
Rectangle().ignoresSafeArea(.all).foregroundColor(.blue).clipShape(
RoundedRectangle(cornerRadius: 20.00)
)
CameraPreviewLayer() // represented by BLACK color
ShutterButton()
}
}
}
Upvotes: 1
Views: 442
Reputation: 2737
Can't you use the .cornerRadius()
attribute on the ztack or cameraPreviewLayer ?
Upvotes: 1