UIKit Dynamics会通过碰撞来改变视图框架

我的项目有几个视图受到母视图中心的径向引力,以及弹性碰撞,因此它们不会重叠。 它工作的很好,但有时我需要调整视图的大小,而当视图变大时,其他视图必须离开视图,以使所有视图保持不重叠。 我期望碰撞行为能够意识到事情是触动的,并将它们分开,但似乎并非如此。

这就是我现在要做的:

[UIView animateWithDuration:0.5 animations:^{ view.frame = CGRectInset(view.frame, -30, -30); } completion:^(BOOL finished) { [self.animator updateItemUsingCurrentState:view]; }]; 

视图长得很好,animation代表被告知animation已经恢复,但其他视图不会移走。 新扩大的视图只是重叠(或根据z顺序underlaps)其他意见。

我试图改变而不是框架 – 没有骰子。 我试图从所有的行为中删除视图 – 没有骰子。 我尝试从animation师中删除一些和所有的行为 – 没有骰子。 我试图调用updateItemUsingCurrentState:在所有的意见 – 没有骰子。 我需要一些骰子!

你能帮我吗? 谢谢…(迅速,随意回答很快,我会翻译它)

感谢这篇文章 ,我了解到,包含被更改项目的所有行为都必须从animation制作者中移除,然后在更改视图的属性后,行为应该被添加回animation师。

我认为这是疯狂的,但它的工作。

 [self.animator removeBehavior:self.behavior]; // for all behaviors that have view as an item [UIView animateWithDuration:0.5 animations:^{ view.frame = CGRectInset(view.frame, -30, -30); } completion:^(BOOL finished) { [self.animator updateItemUsingCurrentState:view]; [self.animator removeBehavior:self.behavior]; }];