iOS动画块:忽略动画命令 [英] iOS animation block: ignores animation commands

查看:100
本文介绍了iOS动画块:忽略动画命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尝试尽可能地简化问题。

I'll try to simplify the problem as much as I can.

我有一个动画块来动画两个UIViewImages。

I have an animation block to animate two UIViewImages.

我在开始之前使用UIImageViews的矩形:

I take the rectangle of the UIImageViews before I start:

我改变:origin.x + = 40两个

I change: origin.x+=40 for both

在动画块中,我将这两个UIImage视图的帧设置为修改后的矩形。

In the animation block, I set the frame of those two UIImage views to the modified rectangles.

它有效。

现在这里有一件事。对于一个的矩形,我还将更改size.width- = 20,使其缩小一点宽度。

Now here's a thing. For one of the rectangles, I'll also change the size.width-= 20 so that it shrinks a bit in width.

结果:收缩和移动发生,但第二个UIImage视图不再移动。就像动画一个元素的宽度/高度一样,取消动画块中的所有其他动画。

The Result: The shrinking and moving takes place, but the second UIImage view will not move anymore. It's as if animating a width/height of an element, cancels out all other animations in the animation block.

我无法弄清楚原因。我已经在这两天了,现在无济于事。有没有人遇到过这样的事情?我在iOS 5.1 Xcode 4.3.2

I can't figure out why. I've been on this for two days now to no avail. Has anyone ever encountered anything like this? I'm on iOS 5.1 Xcode 4.3.2

推荐答案

即使框架属性可以动画,也不是推荐的方式为视图设置动画。

Even though the frame property can be animated, it is not the recommended way to animate a view.

相反,我建议您应用CGAffineTransform来转换UIImageView的属性。

Instead I suggest that you apply a CGAffineTransform to transform property of the UIImageView.

以下是文档链接: https:// developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGAffineTransform/Reference/reference.html

在您的情况下,您会申请缩放和平移转换为图像视图。请记住,如果您想要应用两个变换,则必须先将它们合并为一个。

In your case, you would apply a scale and translation transform to your image views. Keep in mind that if you want to apply two transforms,you will have to combine them into one first.

这篇关于iOS动画块:忽略动画命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆