gpt4 book ai didi

ios - 我可以进行半个 m34 转换吗

转载 作者:行者123 更新时间:2023-11-29 11:20:18 25 4
gpt4 key购买 nike

我想做一个完整的旋转,但在中途交换图像,我似乎无法做到这一点。完整的旋转可以在下面看到。我怎么能用漂亮的 z 轴东西做一半呢?这是在 animateWithDuration block 中 (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);

最佳答案

你可以用两个 block 来做到这一点:

// 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 属性,它隐藏 View 的背面 - 尽管您仍然需要在动画结束,否则第一个 View 的按钮仍可点击。

希望对您有所帮助!谢谢。

关于ios - 我可以进行半个 m34 转换吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7575009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com