Search code examples
ioscore-animationavfoundationios-camera

iOS 7 create flip animation like rotate animation in native camera app


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,


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];