0

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.

2 Answers2

7

UIImagePicker has a property called cameraFlashMode you can set

imagePicker.cameraFlashMode = .on
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
  • Thanks @Leonardo for your suggestions. But do I need to create a IBAction button for the flash button or there is a button already available in xcode 6.3 that has camera-flash button, then I will just drag and drop to the controller? Also, how will user see on the screen that he/she has selected auto or on or off flash, like we see in ios camera app? – alfresco_developer May 06 '15 at 15:07
  • It should have an option for that at least it shows for me by default – Leo Dabus May 06 '15 at 15:25
  • https://www.dropbox.com/s/nmh5vyjr1b5yhni/file%20may%2006%2C%2012%2029%2055%20pm.png?dl=0 – Leo Dabus May 06 '15 at 15:31
  • Thanks @Leonardo, you mean that UIImagePickController show me the option. How about cropping an image, if I capture an image then how will able to crop corner to corner like any scan app does? – alfresco_developer May 06 '15 at 17:00
0

In iOS 4.0 and later, you can provide custom controls to let the user adjust flash mode (on devices that have a flash LED), pick which camera to use (on devices that have a front and rear camera), and switch between still image and movie capture.

You can also manage these settings programmatically. You can also manipulate the flash directly to provide effects such as a strobe light. Present a picker interface set to use video capture mode. Then, turn the flash LED on or off by setting the cameraFlashMode property to UIImagePickerControllerCameraFlashModeOn or UIImagePickerControllerCameraFlashModeOff.

Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
  • Thanks @VIvek for your suggestions. But do I need to create a IBAction button for the flash button or there is a button already available in xcode 6.3 that has camera-flash button, then I will just drag and drop to the controller? Also, how will user see on the screen that he/she has selected auto or on or off flash, like we see in ios camera app? – alfresco_developer May 06 '15 at 15:06