flashMode
A setting for whether to fire the flash when capturing photos.
Declaration
var flashMode: AVCaptureDevice.FlashMode { get set }Discussion
The default value for this setting is AVCaptureDevice.FlashMode.off.
Assuming a static scene, using the AVCaptureDevice.FlashMode.auto setting is equivalent to testing the AVCapturePhotoOutput isFlashScene property (which indicates whether flash is recommended for the scene currently visible to the camera), and then setting the flashMode property of your photo settings output accordingly before requesting a capture. However, the visible scene can change between when you request a capture and when the camera hardware captures an image—the automatic setting ensures that the flash is enabled or disabled appropriately at the moment of capture. When the capture occurs, your AVCapturePhotoCaptureDelegate methods receive an AVCaptureResolvedPhotoSettings object whose isFlashEnabled property indicates which flash mode was used for that capture.
When specifying a flash mode, the following requirements apply:
The specified mode must be present in the photo output’s supportedFlashModes array.
You may not enable image stabilization if the flash mode is AVCaptureDevice.FlashMode.on. (Enabling the flash takes priority over the isAutoStillImageStabilizationEnabled setting).
The capture output validates these requirements when you call the capturePhoto(with:delegate:) method. If your settings don’t meet these requirements, that method raises an exception.
See Also
Configuring photo settings
isAutoRedEyeReductionEnabledmaxPhotoDimensionsphotoQualityPrioritizationisCameraCalibrationDataDeliveryEnabledisAutoContentAwareDistortionCorrectionEnabledisAutoVirtualDeviceFusionEnabledvirtualDeviceConstituentPhotoDeliveryEnabledDevicesisDualCameraDualPhotoDeliveryEnabledisAutoDualCameraFusionEnabledisAutoStillImageStabilizationEnabledisHighResolutionPhotoEnabled