UIImagePickerController how to do animated switch from rear to front camera?

前端 未结 2 1547
耶瑟儿~
耶瑟儿~ 2021-02-18 15:59

I have been using custom overlay for UIImagePickerController controller, and everything is working fine. I have added button to switch between front and rear camera

相关标签:
2条回答
  • 2021-02-18 16:17

    I was trying to do this today, and I was able to get it working with the following code:

    [UIView transitionWithView:imagePickerController.view duration:1.0 options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionTransitionFlipFromLeft animations:^{
                imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
            } completion:NULL];
    

    I hope this helps anyone who comes across this question.

    0 讨论(0)
  • 2021-02-18 16:33

    Here's the Swift code for the accepted answer in case someone needs it:

    UIView.transitionWithView(imagePickerController.view!, duration: 1.0, options: [.AllowAnimatedContent, .TransitionFlipFromLeft], animations: {() -> Void in
                imagePickerController.cameraDevice = .Rear
                }, completion: nil)
    

    Thanks Pablo!

    0 讨论(0)
提交回复
热议问题