iOS 7创建翻转动画,如在原生相机应用程序中旋转动画

时间:2013-11-15 06:30:18

标签: ios core-animation avfoundation ios-camera

我正在使用AVFoundation创建带有自定义相机的iOS应用程序。 我的问题是相机旋转,预览层有改变前/后相机,如何生成动画像本机相机应用程序。 翻转动画?

谢谢,

1 个答案:

答案 0 :(得分:4)

试试这个:

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