Q:

UIImagePickerController custom FlashMode button is not working on IOS 10 (swift)

I know that a question of this type is already asked but I Debugged it in bit detail, and i came to this point that when i switched this flag off 
   self.picker.showsCameraControls = false

then the custom flash button doesn't respond but if I'll change the flag to 
   self.picker.showsCameraControls = true

then my custom flash button responding OK, I have check all the delegates and flags but I am not able to pin point the bug, either it is in my code or it is in IOS 10 version, if its in my code then on showing camera controls why my custom flash button changes state of flash and work fine.
here is my code for better understanding:
   func configureImagePicker(){
         self.picker.delegate = self
         self.picker.allowsEditing = false
        if       UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)
    {
        self.picker.sourceType = UIImagePickerControllerSourceType.Camera
        self.picker.mediaTypes = [kUTTypeImage as String]
    }
}

  func showImagePicker(){
    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){

        self.picker.sourceType = UIImagePickerControllerSourceType.Camera
        self.picker.showsCameraControls = false
        self.picker.delegateController = self
        self.picker.delegate = self
        self.picker.mediaTypes = [kUTTypeImage as String]
        self.picker.allowsEditing = false

        if let cameraOverlay = self.picker.cameraOverlayView {

            self.createCamerOverlay(cameraOverlay.frame)
            self.picker.cameraOverlayView = self.overlayView

            self.presentViewController(self.picker, animated: false, completion: {
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(Double(0.5)*Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {
                    if self.picker.cameraDevice == UIImagePickerControllerCameraDevice.Rear && UIImagePickerController.isFlashAvailableForCameraDevice(UIImagePickerControllerCameraDevice.Rear)
                    {
                        if Float.init(UIDevice.currentDevice().systemVersion) < 11.0
                        {
                            switch(Global.shared.currenFlashOption)
                            {
                                case .FlashOff:
                                    self.picker.cameraFlashMode = .Off
                                    let flashImage = UIImage(named: "btn-flash-off")
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Normal)
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Highlighted)
                                case .FlashAuto:
                                    self.picker.cameraFlashMode = .Auto
                                    let flashImage = UIImage(named: "btn-flash")
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Normal)
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Highlighted)
                                case .FlashOn:
                                    self.picker.cameraFlashMode = .On
                                    let flashImage = UIImage(named: "btn-flash-on")
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Normal)
                                    self.flashButton.setImage(flashImage, forState: UIControlState.Highlighted)
                            }
                        }
                        else
                        {
                            self.picker.cameraFlashMode = UIImagePickerControllerCameraFlashMode.On

                        }
                    }
                });
            });

        } else {
            print("Camera overlay frame not found. So did not present the controller.")
        }
    }
    else{
        let alert = UIAlertView(title: "Error", message: "Camera Not Available", delegate: nil, cancelButtonTitle: "Cancel")
        alert.show()
    }
}

In short my custom flashmode button is not working on cameraoverlayview. 
if there is no solution to this problem then please suggest any hack.
thanks

A:

I've solved my problem with a clumsy hack,
 self.picker.showsCameraControls = true
 self.picker.cameraFlashMode = .On
 self.picker.showsCameraControls = false

It is fast enough to not disturb user with the showing and hiding controls.
It Worked!

