Maybe I'm wrong, but in a brief example, it looked like this:
Highlight the UIDynamicItemBehavior for the item (s) in question:
self.itemBehaviorInQuestion = [[UIDynamicItemBehavior alloc] initWithItems:@[self.infoView]]; self.itemBehaviorInQuestion.resistance = 0; self.collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.infoView]]; self.collisionBehavior.collisionDelegate = self; [self.animator addBehavior:self.collisionBehavior]; [self.animator addBehavior:self.itemBehaviorInQuestion];
Implement the following UICollisionBehavior delegation methods:
- (void)collisionBehavior:(UICollisionBehavior *)behavior beganContactForItem:(id<UIDynamicItem>)item withBoundaryIdentifier:(id<NSCopying>)identifier atPoint:(CGPoint)p { self.itemBehaviorInQuestion.resistance = 100; } - (void)collisionBehavior:(UICollisionBehavior *)behavior endedContactForItem:(id<UIDynamicItem>)item withBoundaryIdentifier:(id<NSCopying>)identifier { self.itemBehaviorInQuestion.resistance = 0; }
Establishing resistance to a large value at this point seems to facilitate the element of its rebound.
Morkrom
source share