2015-06-07 4 views
0

Я хочу создать анимированный пузырь, похожий на тот, который приведен ниже. С той же расширяющейся/сжатой анимацией отскока. Кто-нибудь знает, как это сделать? Это просто UIView с анимацией? Какой анимационный эффект? Любые указатели на то, как это сделать, будут действительно оценены. Благодаря!Как создать анимацию popover popover, как это?

enter image description here

ответ

4

Вы можете использовать

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

enter image description here

+0

Это замечательно! Большое вам спасибо за ваш ответ. – KexAri

1

Я думаю, это 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; 
}} 
Смежные вопросы