Swiftui flash won't work when capturing photo

Viewed 35

The flash doesn't work when capturing a photo.

First, I enable the flash:

@Published var flashMode: AVCaptureDevice.FlashMode = .on

Then I update the settings before I take a photo:

func takePic() {
        
        DispatchQueue.main.async {
            
            let photoSettings = AVCapturePhotoSettings()
            photoSettings.flashMode = self.flashMode

            self.output.capturePhoto(with:  photoSettings, delegate: self)

            self.session.stopRunning()
            
            DispatchQueue.main.async {
                
                withAnimation{self.isTaken.toggle()}
            }

        }
        
    }

Any idea what I'm doing wrong?

0 Answers
Related