我试图重新创建UIViewAnimationTransitionFlipFromRight(和左)。如下所示,我的理由是在动画中间改变AVCaptureVideoPreviewLayer,当图层被遮挡时。 UIViewAnimationTransitionFlipFromRight不会让我停止一半动画,改变会话并继续,所以这里是我最好的选择。使用CATransform3D创建翻转动画
虽然这工作,它只是不同于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
}
];
}
}
];
我肯定会尝试。在我的监督下,我会更新OP。 – 2011-04-10 02:41:31
我还发现,它似乎在我第一次调用它时会执行正确的动画,但是每隔一段时间,它都会将动画做一半并自行反转。 – 2011-04-11 02:40:38