Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change bounds of UIView and have UICollisionBehavior react to it

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.

like image 958
Tom Nys Avatar asked Jan 28 '26 23:01

Tom Nys


1 Answers

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];
    }
}
like image 107
Jason Harris Avatar answered Jan 30 '26 16:01

Jason Harris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!