你可以用两个块来做到这一点:
// Rotate the second 'backside' view to 90 degrees and hide it
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
mySecondView.layer.transform = transform;
mySecondView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);
mySecondView.hidden = YES;
// Animate to 90 degrees
[UIView animateWithDuration:0.5 animations:^{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
myView.layer.transform = transform;
myView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);
} completion:^{
// Switch to the backside view
myView.hidden = YES;
mySecondView.hidden = NO;
// Animate the remaining 90 degrees
[UIView animateWithDuration:0.5 animations:^{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
mySecondView.layer.transform = transform;
mySecondView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0);
}
}
您还可以体验myView.layer.isDoubleSided
隐藏视图背面的属性 - 尽管您仍然需要hidden
在动画结束时切换标志,否则第一个视图的按钮仍然是可点击的。
希望这可以帮助!谢谢。