1

用正确的观察进行编辑。

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

如果我应用更改锚点的线,视图会正确摆动(右侧铰链),但存在一个主要问题:视图的大小恢复到原始大小(更小),而(旋转)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) {
    }];
}
4

1 回答 1

1

您需要使用持续时间将“选项”添加到动画中并添加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) {
    }];
}
于 2013-06-04T03:24:26.557 回答