I would like to know if it\'s possible to receive notification about autofocus inside an iPhone application?
I.E, does it exist a way to be notified when autofocus s
You can use modern Swift key value observing api to get callbacks when focusing starts and ends by observing AVCaptureDeviceInput.device.isAdjustingFocus
property. In the example below, instance of AVCaptureDeviceInput
is called captureDeviceInput
.
Example:
self.focusObservation = observe(\.captureDeviceInput.device.isAdjustingFocus, options: .new) { _, change in
guard let isAdjustingFocus = change.newValue else { return }
print("isAdjustingFocus = \(isAdjustingFocus)")
}