用正确的观察进行编辑。
我使用了以下两个代码片段来旋转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) {
}];
}发布于 2013-06-04 11:24:27
您需要添加“选项”到您的动画与持续时间和添加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) {
}];
}https://stackoverflow.com/questions/16908331
复制相似问题