@@ -25,7 +25,7 @@ public class CameraView: UIView {
2525
2626 public func startSession( ) {
2727 session = AVCaptureSession ( )
28- session. sessionPreset = AVCaptureSessionPresetPhoto
28+ session. sessionPreset = AVCaptureSession . Preset . photo
2929
3030 device = cameraWithPosition ( position: currentPosition)
3131 if let device = device , device. hasFlash {
@@ -107,7 +107,7 @@ public class CameraView: UIView {
107107 addGestureRecognizer ( pinchGesture)
108108 }
109109
110- internal func focus( gesture: UITapGestureRecognizer ) {
110+ @ objc internal func focus( gesture: UITapGestureRecognizer ) {
111111 let point = gesture. location ( in: self )
112112
113113 guard focusCamera ( toPoint: point) else {
@@ -141,7 +141,7 @@ public class CameraView: UIView {
141141 } )
142142 }
143143
144- internal func pinch( gesture: UIPinchGestureRecognizer ) {
144+ @ objc internal func pinch( gesture: UIPinchGestureRecognizer ) {
145145 guard let device = device else { return }
146146
147147 // Return zoom value between the minimum and maximum zoom values
@@ -175,14 +175,14 @@ public class CameraView: UIView {
175175 private func createPreview( ) {
176176
177177 preview = AVCaptureVideoPreviewLayer ( session: session)
178- preview. videoGravity = AVLayerVideoGravityResizeAspectFill
178+ preview. videoGravity = AVLayerVideoGravity . resizeAspectFill
179179 preview. frame = bounds
180180
181181 layer. addSublayer ( preview)
182182 }
183183
184- private func cameraWithPosition( position: AVCaptureDevicePosition ) -> AVCaptureDevice ? {
185- guard let devices = AVCaptureDevice . devices ( withMediaType : AVMediaTypeVideo ) as? [ AVCaptureDevice ] else {
184+ private func cameraWithPosition( position: AVCaptureDevice . Position ) -> AVCaptureDevice ? {
185+ guard let devices = AVCaptureDevice . devices ( for : AVMediaType . video ) as? [ AVCaptureDevice ] else {
186186 return nil
187187 }
188188 return devices. filter { $0. position == position } . first
@@ -218,7 +218,7 @@ public class CameraView: UIView {
218218 return false
219219 }
220220
221- let focusPoint = preview. captureDevicePointOfInterest ( for : toPoint)
221+ let focusPoint = preview. captureDevicePointConverted ( fromLayerPoint : toPoint)
222222
223223 device. focusPointOfInterest = focusPoint
224224 device. focusMode = . continuousAutoFocus
@@ -258,11 +258,11 @@ public class CameraView: UIView {
258258 session. beginConfiguration ( )
259259 session. removeInput ( currentInput)
260260
261- if currentInput. device. position == AVCaptureDevicePosition . back {
262- currentPosition = AVCaptureDevicePosition . front
261+ if currentInput. device. position == AVCaptureDevice . Position . back {
262+ currentPosition = AVCaptureDevice . Position . front
263263 device = cameraWithPosition ( position: currentPosition)
264264 } else {
265- currentPosition = AVCaptureDevicePosition . back
265+ currentPosition = AVCaptureDevice . Position . back
266266 device = cameraWithPosition ( position: currentPosition)
267267 }
268268
@@ -283,16 +283,16 @@ public class CameraView: UIView {
283283 }
284284 switch UIApplication . shared. statusBarOrientation {
285285 case . portrait:
286- preview? . connection. videoOrientation = AVCaptureVideoOrientation . portrait
286+ preview? . connection? . videoOrientation = AVCaptureVideoOrientation . portrait
287287 break
288288 case . portraitUpsideDown:
289- preview? . connection. videoOrientation = AVCaptureVideoOrientation . portraitUpsideDown
289+ preview? . connection? . videoOrientation = AVCaptureVideoOrientation . portraitUpsideDown
290290 break
291291 case . landscapeRight:
292- preview? . connection. videoOrientation = AVCaptureVideoOrientation . landscapeRight
292+ preview? . connection? . videoOrientation = AVCaptureVideoOrientation . landscapeRight
293293 break
294294 case . landscapeLeft:
295- preview? . connection. videoOrientation = AVCaptureVideoOrientation . landscapeLeft
295+ preview? . connection? . videoOrientation = AVCaptureVideoOrientation . landscapeLeft
296296 break
297297 default : break
298298 }
0 commit comments