我正在尝试使按钮弹出菜单按钮(类似于路径上的+按钮),并使用UIDynamicAnimator动画按钮的进出。它的工作原理和代码非常简单。
_animator = [[UIDynamicAnimator alloc] initWithReferenceView:sender.superview];
UIDynamicItemBehavior *resistance = [[UIDynamicItemBehavior alloc] initWithItems:@[_cartBtn, _chatBtn, _eventBtn]];
resistance.resistance = 5.0f;
[_animator addBehavior:resistance];
CGFloat radius = 75;
CGPoint target = sender.center;
target.x += radius * cos(GLKMathDegreesToRadians(265));
target.y += radius * sin(GLKMathDegreesToRadians(265));
UISnapBehavior *snapBehavior = [[UISnapBehavior alloc] initWithItem:_cartBtn snapToPoint:target];
[_animator addBehavior:snapBehavior];
target = sender.center;
target.x += radius * cos(GLKMathDegreesToRadians(225));
target.y += radius * sin(GLKMathDegreesToRadians(225));
UISnapBehavior *snapBehavior2 = [[UISnapBehavior alloc] initWithItem:_chatBtn snapToPoint:target];
[_animator addBehavior:snapBehavior2];
target = sender.center;
target.x += radius * cos(GLKMathDegreesToRadians(185));
target.y += radius * sin(GLKMathDegreesToRadians(185));
UISnapBehavior *snapBehavior3 = [[UISnapBehavior alloc] initWithItem:_eventBtn snapToPoint:target];
[_animator addBehavior:snapBehavior3];就这样,所有三个按钮一起弹出。我想问的是,是否可以使用UIDynamicAnimator或其他简单的方法使按钮一个接一个地显示出来?
发布于 2016-04-13 06:12:32
显然,我只需要在[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; addBehavior:之间添加一个很小的延迟
https://stackoverflow.com/questions/36567921
复制相似问题