如何创建这样的弹跳弹出动画?

How do I create a bouncing popover animation like this?

我想创建一个如下图所示的动画弹出气泡。使用相同的 expanding/contracting 弹跳动画。有谁知道该怎么做?只是一个带动画的 UIView 吗?这是什么动画效果?任何关于如何解决这个问题的指示将不胜感激。谢谢!

您可以使用

Obj-C:

animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:animations completion: 方法如下:

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 })

我认为是UIPopoverPresentationController。 样本:

-(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;
}}