Search code examples
iosswiftuiimagepickercontrollercamera-flash

Camera Flash Turn Auto/On/Off with UIImagePickerController in IOS - Swift


I am very new to IOS Swift. But I am building a sample camera app that takes picture and video and then saved to photo gallery. But I want user to choose Auto/On/Off Flash option on the Camera View and when the user takes the picture then flash turns on or turns off depending on option what he/she chooses. I am using UIImagePickerController to customize camera features. I couldn't get much suggestions so far on how can I able to On/Off feature on the camera view and the camera flash works simultaneously while pressing button.

Is there any Camera Flash capability presented in UIImagePickerController already? If so, then how can I add or use with my code I have so far, so flash and taking picture works together.

Any help with the swift example regarding how can I able to add the flash capability in my controller and how to work at the same time while taking picture? Can someone please point me towards the right direction. Any help will be greatly appreciated.


Solution

  • UIImagePicker has a property called cameraFlashMode you can set

    imagePicker.cameraFlashMode = .on