gpt4 book ai didi

ios - 应用 anchor 后 CATransform3DRotate 效果消失

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

通过正确的观察进行编辑。

我使用以下两个片段来旋转 UIImageView。在 stage1 之后,我得到了想要的 3D 效果: View 旋转(3D 效果)和拉伸(stretch)(更大尺寸)。在 stage2 上,我试图通过右侧的铰链摆动 rightView。

如果我应用更改 anchor 的线, View 会正确摆动(铰链在右侧),但有一个主要问题: View 的大小恢复到原始大小(较小),而(旋转)3D 效果仍然完好无损然后摆动发生。

有什么建议吗?

rightView.layer.anchorPoint = CGPointMake(1.0, 0.5); 


-(void)stage1
{
[UIView animateWithDuration:1.5 animations:^{
rightView.transform = CGAffineTransformMakeTranslation(0,0); //rightView i UIImageView
CATransform3D _3Dt = CATransform3DIdentity;
_3Dt =CATransform3DMakeRotation(3.141f/42.0f,0.0f,-1.0f,0.0f);
_3Dt.m34 = -0.001f;
_3Dt.m14 = -0.0015f;
rightView.layer.transform = _3Dt;
} completion:^(BOOL finished){
if (finished) {
NSLog(@"finished..");
}
}];
}

-(void)Stage2
{
rightView.layer.anchorPoint = CGPointMake(1.0, 0.5); //issue?
rightView.center = CGPointMake(1012, 384);
[UIView animateWithDuration:1.75 animations:^{
CATransform3D rightTransform = rightView.layer.transform;
rightTransform.m34 = 1.0f/500;
rightTransform = CATransform3DRotate(rightTransform, M_PI_2, 0, 1, 0);
rightView.layer.transform = rightTransform;
} completion:^(BOOL finished) {
}];
}

最佳答案

您需要将“选项”添加到带有持续时间的动画并添加 options:UIViewAnimationOptionBeginFromCurrentState

否则从头开始。

所以你的第 2 阶段看起来像这样:

-(void)Stage2
{
rightView.layer.anchorPoint = CGPointMake(1.0, 0.5); //issue?
rightView.center = CGPointMake(1012, 384);
[UIView animateWithDuration:1.75
delay:0.00
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
CATransform3D rightTransform = rightView.layer.transform;
rightTransform.m34 = 1.0f/500;
rightTransform = CATransform3DRotate(rightTransform, M_PI_2, 0, 1, 0);
rightView.layer.transform = rightTransform;
} completion:^(BOOL finished) {
}];
}

关于ios - 应用 anchor 后 CATransform3DRotate 效果消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16908331/

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