我想做一个完整的旋转,但是图像交换中途,我似乎无法做到这一点。完整的旋转可以在下面看到。我怎么能用这个漂亮的z轴做一半呢?这是在animateWithDuration块(iOS4)
中// Create perspective transformation
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
myView.layer.transform = transform; //- 3d
myView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0);
答案 0 :(得分:2)
你可以用两个块来做到这一点:
// 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
标志,否则第一个视图的按钮将会仍然是可点击的。
希望这有帮助!感谢。