IOS SDK: how to make browsing switch when switching cameras

Quite new in iOS / Objective C. I make Apple AVCam mods (video recording) of the sample code and would like to emulate the built-in animation of the camera flip engine when switching between the front and rear cameras. It seems that it will be easy, but I can not understand how this is done. Council will be happy.

Thanks!

Mark

+4
source share
1 answer

This is a really easy task. All you have to do is call the transitionWithView method from the UIView just before changing the previewView input.

If you're targeting iOS 8.0 or later, you can also easily add a blur effect.

In Swift:

 let blurView = UIVisualEffectView(frame: previewView.bounds) blurView.effect = UIBlurEffect(style: .Light) previewView.addSubview(blurView) UIView.transitionWithView(previewView, duration: 0.4, options: .TransitionFlipFromLeft, animations: nil) { (finished) -> Void in blurView.removeFromSuperview() } 

Objective-C:

 UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithFrame:_previewView.bounds]; blurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; [_previewView addSubview:blurView]; [UIView transitionWithView:_previewView duration:0.4 options:UIViewAnimationOptionTransitionFlipFromLeft animations:nil completion:^(BOOL finished) { [blurView removeFromSuperview]; }]; 
+5
source

Source: https://habr.com/ru/post/1411212/


All Articles