Change bounds of UIView and have UICollisionBehavi

2019-03-31 12:25发布

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条回答
女痞
2楼-- · 2019-03-31 12:53

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];
    }
}
查看更多
登录 后发表回答