Question

I am working with AVFoundation for create iOS app with custom camera. My problem is camera rotate, the preview layer with be changed front/back camera, how to produce animation like native camera app. Flip Animation ?

Thanks,

Was it helpful?

Solution

Try this:

CATransition *animation = [CATransition animation];
animation.duration = .5f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = @"oglFlip";
if (captureDevice.position == AVCaptureDevicePositionFront) {
    animation.subtype = kCATransitionFromRight;
}
else if(captureDevice.position == AVCaptureDevicePositionBack){
    animation.subtype = kCATransitionFromLeft;
}
[capturePreviewLayer addAnimation:animation forKey:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top