You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PhotoCameraDemo/PhotoCameraDemo/Sources/CameraView/CameraView.swift
+20-18Lines changed: 20 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -39,27 +39,29 @@ struct CameraView: View {
39
39
GeometryReader{ proxy in
40
40
// A container view that manages the placement of the preview.
41
41
viewfinderContainer(viewSize: proxy.size){
42
-
// A view that provides a preview of the captured content.
43
-
iflet capturedImage {
44
-
Image(uiImage: capturedImage)
45
-
.resizable()
46
-
.aspectRatio(contentMode:.fill)
47
-
}
48
-
else{
49
-
ViewfinderView(camera: camera)
50
-
// Handle capture events from device hardware buttons.
51
-
.onCameraCaptureEvent{ event in
52
-
if event.phase ==.ended {
53
-
capturePhoto()
54
-
}
42
+
ViewfinderView(camera: camera)
43
+
// Handle capture events from device hardware buttons.
44
+
.onCameraCaptureEvent{ event in
45
+
if event.phase ==.ended {
46
+
capturePhoto()
55
47
}
48
+
}
56
49
57
-
// Focus and expose at the tapped point.
58
-
.onTapGesture{ location in
59
-
Task{await camera.focusAndExpose(at: location)}
50
+
// Focus and expose at the tapped point.
51
+
.onTapGesture{ location in
52
+
Task{await camera.focusAndExpose(at: location)}
53
+
}
54
+
.opacity(blink ?0:1)
55
+
56
+
// A view that provides a preview of the captured content.
57
+
.overlay{
58
+
// This is done as an overlay because hiding and showing the video layer (ViewfinderView above) without restarting the session causes strange problems on macOS, though is fine on the iPhone.
0 commit comments