How do I create a bouncing popover animation like this?

3k Views Asked by At

I want to create an animated popover bubble like the one below. With the same expanding/contracting bounce animation. Does anyone know how to go about this? Is is just a UIView with animation? What animation effect is this? Any pointers on how to go about this would be really appreciated. Thanks!

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

You can use the

Obj-C:

animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:animations completion: method like this:

UIView *animationView = [[UIView alloc] initWithFrame:CGRectMake(50, 90, 100, 50)];
animationView.backgroundColor = [UIColor redColor];
animationView.transform = CGAffineTransformMakeScale(0, 0);
[self.view addSubview:animationView];

[UIView animateWithDuration:0.3
                      delay:0
     usingSpringWithDamping:0.5
      initialSpringVelocity:5
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     animationView.transform = CGAffineTransformIdentity;
                 }
                 completion:nil];

Swift:

var animationView: UIView = UIView(frame: CGRectMake(50, 90, 100, 50))
animationView.backgroundColor = UIColor.redColor()
animationView.transform = CGAffineTransformMakeScale(0, 0)
self.view!.addSubview(animationView)
UIView.animateWithDuration(0.3, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 5, options: .CurveEaseInOut, animations: {() -> Void in
    animationView.transform = CGAffineTransformIdentity
}, completion: { _ in })

enter image description here

0
On

i think it is UIPopoverPresentationController. sample:

-(void)showPopover:(UIBarButtonItem*)sender{
if(!_btnController){
    _btnController = [[ButtonsViewController alloc] init];
    _btnController.delegate = self;
}
if (_popover == nil) {
    _btnController.modalPresentationStyle = UIModalPresentationPopover;
    UIPopoverPresentationController *pc = [ _btnController popoverPresentationController];
    pc.barButtonItem = sender;
    pc.permittedArrowDirections = UIPopoverArrowDirectionAny;
    pc.delegate = self;
    [self presentViewController: _btnController animated:YES completion:nil];
} else {
    //The color picker popover is showing. Hide it.
    [_popover dismissPopoverAnimated:YES];
    _popover = nil;
}}