【发布时间】:2013-06-04 01:15:51
【问题描述】:
用正确的观察进行编辑。
我使用以下两个 sn-ps 来旋转 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) {
}];
}
【问题讨论】:
-
更改锚点也会改变应用转换的方式。您能否生成所需结果的图像,例如Photoshop?初始状态,stage1动画完成时的状态,stage2动画完成时的状态?
-
@hfossli,图片已添加。我还在 stage2 动画发生之前添加了一张图片。注意,我可以在 stage2 动画之前使用 setFrame 更改为 rightView 的帧,但是在 stage1 动画之后我无法让它匹配原始的 3D 效果(角度等)。
-
你上传的图片是想要的输出还是“错误”的输出?
-
@hfossli,这是错误的。图片 4 是动画图片 3 而不是图片 2 的结果。图片 3,如您所见,anchorPoint 设置改变了图片 2 的大小。
-
如果省略 rightView.center = CGPointMake(1012, 384); 会发生什么?还是放在动画里?我认为这会使视图在第二个动画开始之前跳转。
标签: ios catransform3d catransform3drotate