我正在尝试重新创建 UIViewAnimationTransitionFlipFromRight (和左)。我这样做的原因如下图所示,是在动画中间,当图层被遮挡时,对 AVCaptureVideoPreviewLayer 进行更改。UIViewAnimationTransitionFlipFromRight 不会让我中途停止动画,进行会话更改并继续,所以这是我最好的镜头。
虽然这可行,但它与 UIViewAnimationTransitionFlipFromRight 不同。图层开始旋转,但更多的是向后和对角滑动(很难描述),然后在动画的第二部分反转。我正在寻找图层的右侧翻转到后面,然后继续向左。相反,右侧从右侧开始,向后旋转,然后再次向右旋转。
我究竟做错了什么?
更新:它第一次正确旋转。之后,上面提到的问题仍然存在。与必须重置的 AVCaptureVideoPreviewLayer 有什么关系吗?不确定,只是猜测。
[UIView animateWithDuration:1.5 delay:0.0
options:UIViewAnimationCurveEaseIn
animations:^{
CATransform3D frontTransform = CATransform3DIdentity;
frontTransform.m34 = 1.0 / -850.0;
frontTransform = CATransform3DMakeRotation(M_PI_2,0.0,1.0,0.0); //flip halfway
frontTransform = CATransform3DScale(frontTransform, 0.835, 0.835, 0.835);
previewLayer.transform = frontTransform;
}
completion:^(BOOL finished){
if (finished) {
[previewLayer setAutomaticallyAdjustsMirroring:NO];
[previewLayer setMirrored:NO];
[session beginConfiguration];
[[self captureManager] setMirroringMode:AVCamMirroringOff];
[session commitConfiguration];
[UIView animateWithDuration:1.5
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
CATransform3D backTransform = CATransform3DIdentity;
backTransform.m34 = 0.0f;
backTransform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0); //finish the flip
backTransform = CATransform3DScale(backTransform, 1.0, 1.0, 1.0);
previewLayer.transform = backTransform;
}
completion:^(BOOL finished){
//nothing upon completion
}
];
}
}
];