Change bounds of UIView and have UICollisionBehavior react to it

870 views Asked by At

Is it possible to change the bounds of a UIView (which is attached to some other UIViews using UIAttachmentBehaviors) and have the UICollisionBehavior in combination with the UIAttachmentBehavior respond to it (like the sample movie here: http://www.netwalkapps.com/ani.mov, whereby upon touch the ball UIView grows and the other ball UIViews move out of the way)?

Thanks! Tom.

1

There are 1 answers

1
Jason Harris On

I got this to work but it was pretty hacky. I had to remove all behaviors from my animator object and re-add them again.

- (void)_tickleBehaviors
{
    NSArray *behaviors = [self.animator.behaviors copy];
    for (UIDynamicBehavior *behavior in self.animator.behaviors) {
        [self.animator removeBehavior:behavior];
    }

    for (UIDynamicBehavior *behavior in behaviors) {
        [self.animator addBehavior:behavior];
    }
}