是否有可能暂停一个UIDynamicAnimator而不删除和添加UIDynamicBehaviours?

我正在使用UIDynamics实现一些animation,以便在视图之间启用一些基于物理的转换。 我想暂停并以编程方式继续这些animation响应用户触摸。 到目前为止,我发现这样做的唯一方法是从dynamicanimation器中删除行为,然后像这样重新添加它们:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.dynamicAnimator removeBehaviour: self.behaviour1]; [self.dynamicAnimator removeBehaviour: self.behaviour2]; // etc } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { self.behaviour1 = [[UIGravityBehavior alloc] initWithItems: @[self.item]]; self.behaviour1.gravityDirection = self.gravityVector; [self.dynamicAnimator addBehaviour: self.behaviour1]; self.behaviour2 = [[UICollisionBehavior alloc] initWithItems: @[self.item]]; [self.behaviour2 addBoundaryWithIdentifier: @"Boundary" forPath: self.boundary]; [self.dynamicAnimator addBehaviour: self.behaviour2]; // etc } 

(另外:我还使用了[self.dynamicAnimator updateItemUsingCurrentState: item]而不是重新创build行为,但是我仍然需要将它们从dynamicanimation中移除,并重新添加它们以便在用户触摸时暂停屏幕。)

我想能做的是self.dynamicAnimator.running = NO暂停,然后self.dynamicAnimator.running = YES继续。 这会更简洁,涉及的代码更less(我目前有五种行为可以做到这一点),并有助于避免过程中的潜在错误。 不幸的是, dynamicAnimator.running属性是只读的,所以不可能。

有没有一种方法可以暂停和延续UIDynamicAnimator?