I don't have a project to work on this with but the following will take a UIButton
and when you click on it, drop it to the bottom of the view, and it will bounce.
- (UIDynamicAnimator *)animator
{
if (!_animator) {
_animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
}
return _animator;
}
- (IBAction)clicked:(id)sender {
UIGravityBehavior *gravity = [[UIGravityBehavior alloc] initWithItems:@[self.button1]];
UICollisionBehavior *collision = [[UICollisionBehavior alloc] initWithItems:@[self.button1]];
collision.translatesReferenceBoundsIntoBoundary = YES;
[self.animator addBehavior:collision];
[self.animator addBehavior:gravity];
}