我想创建一个像下面那样的动画弹出式泡泡。使用相同的扩展/收缩反弹动画。有谁知道如何去做?是动画的UIView吗?这是什么动画效果?关于如何解决这个问题的任何指示都将非常感激。谢谢!
答案 0 :(得分:5)
您可以使用
的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];
夫特:
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 })
答案 1 :(得分: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;
}}