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

青春壹個敷衍的年華 提交于 2019-12-08 07:26:04

问题


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.


回答1:


UIImagePicker has a property called cameraFlashMode you can set

imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashMode.On



回答2:


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.



来源:https://stackoverflow.com/questions/30067202/camera-flash-turn-auto-on-off-with-uiimagepickercontroller-in-ios-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!