Iphone 如何结合缩放和平移动画 我试图做一个UIVIEW动画,我的图像从屏幕左上方开始,扩展到屏幕中间的原始大小和位置。到目前为止,我已经能够使它单独做这件事,但当我试图结合这些动画,它只会做缩放动画

Iphone 如何结合缩放和平移动画 我试图做一个UIVIEW动画,我的图像从屏幕左上方开始,扩展到屏幕中间的原始大小和位置。到目前为止,我已经能够使它单独做这件事,但当我试图结合这些动画,它只会做缩放动画,iphone,objective-c,translation,scale,cgaffinetransform,Iphone,Objective C,Translation,Scale,Cgaffinetransform,有没有一种方法可以同时使用缩放和翻译 以下是我到目前为止的情况: CGAffineTransform setpointTrans = CGAffineTransformMakeTranslation(-200.0f, -200.0f); CGAffineTransform setpointScale = CGAffineTransformMakeScale(0.0f, 0.0f); _RSEImage.transform = CGAffineTransformConcat(setpointTra

有没有一种方法可以同时使用缩放和翻译

以下是我到目前为止的情况:

CGAffineTransform setpointTrans = CGAffineTransformMakeTranslation(-200.0f, -200.0f);
CGAffineTransform setpointScale = CGAffineTransformMakeScale(0.0f, 0.0f);
_RSEImage.transform = CGAffineTransformConcat(setpointTrans, setpointScale);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
CGAffineTransform scaleTrans  = CGAffineTransformMakeScale(1.0f, 1.0f);
CGAffineTransform lefttorightTrans  = CGAffineTransformMakeTranslation(0.0f,0.0f);
_RSEImage.transform = CGAffineTransformConcat(scaleTrans, lefttorightTrans);
[UIView commitAnimations];
好吧,我想出来了,这是我改变的:

_RSEImage.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
CGAffineTransform scaleTrans  = CGAffineTransformMakeScale(1.0f, 1.0f);
CGAffineTransform lefttorightTrans  = CGAffineTransformMakeTranslation(200.0f,200.0f);
_RSEImage.transform = CGAffineTransformConcat(scaleTrans, lefttorightTrans);
[UIView commitAnimations];

也可以使用动画块(来自iOS4):

相关官方文件如下:

很好的教程:


希望有帮助

我试用了你的代码,它完美地实现了你想要实现的目标:放大和翻译。。。在这个代码之前,重影的原点是什么?x160 y 242,我想这就是你要问的,对不起,这是我的第一个iphone应用程序。图像大小为161 x 71很难从这段代码中分辨出问题出在哪里,因为基本上这段代码片段是有效的,这是进行仿射变换“合并”的方式。所以我猜你的代码的其他部分会以某种方式阻止翻译,或者不可见。。。开始通过注释逐渐添加函数,并检查直到这一点,一切看起来都很好。检查这段代码的前3行,比例为0.3f,平移为-100f,你看到img了吗?然后单独添加平移以测试参数,然后使用scale合并。。你也可以使用我的答案,因为块更容易。只将图像缩放到其大小的两倍,它仍然没有将图像从左上角移到中间。奇怪的事情发生了…;-)什么是_RSEImage类型,你能分享你如何添加到视图中的代码吗?或者任何其他与RSEImage相关的代码?我找到了它并编辑了我的问题,我将学习这些代码块,看起来容易多了。谢谢你的帮助。不客气!;)如果你接受这个答案,它可能也会帮助其他人。谢谢!
[UIView animateWithDuration: 5
                      delay: 0
                    options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                 animations:^{_RSEImage.center = CGPointMake(300, 300) ; _RSEImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0);}
                 completion:^(BOOL finished) { }
 ];