我想要做的是立即翻转此UIImageView
,不动画,然后我需要它float
到它在屏幕上的预定位置。 transformations
都有效,但不是我想要的方式。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
resultsEnemy.transform = CGAffineTransformMakeTranslation(0, 0);
[UIView commitAnimations];
resultsEnemy.transform = CGAffineTransformMakeScale(-1, 1);
这是我正在使用的代码。尽管缩放代码(我用来翻转UIImageView
)不是0.5 duration
动画的一部分,但它遵循这些规则。我该如何避免这种情况?
答案 0 :(得分:0)
应用这样的两个变换不会产生您期望的结果。您需要做的是将它们组合成一个变换矩阵。以下内容应按预期工作。
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
// Create two separate transforms and concatenate them together.
// Use that new transform matrix to accomplish both transforms at once.
CGAffineTransform translate = CGAffineTransformMakeTranslation(0, 0);
CGAffineTransform scale = CGAffineTransformMakeScale(-1, 1);
resultsEnemy.transform = CGAffineTransformConcat(translate, scale);
[UIView commitAnimations];
编辑:根据您的澄清,您似乎想要这样的事情:
CGAffineTransform scale = CGAffineTransformMakeScale(-1, 1);
CGAffineTransform translate = CGAffineTransformMakeTranslation(0, 0);
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
resultsEnemy.transform = scale;
[CATransaction commit];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
resultsEnemy.transform = CGAffineTransformConcat(translate, scale);
[UIView commitAnimations];