我想用UIKitDynamics给一些按钮添加动画,但是用UISnapBehaviour做一些非常基础的事情根本不起作用。我使用IB来布局我所有的子视图,所以请记住,我不能通过调用self.button.frame来重新定位任何东西,您必须使用约束。
这就是说,我在这里have...When,我运行动画,它很快地闪烁,看起来很糟糕。
// Position the buttons off screen
self.swerveButton.translatesAutoresizingMaskIntoConstraints = NO;
self.followButton.translatesAutoresizingMaskIntoConstraints = NO;
self.swerveButtonTopSpaceConstraint.constant = -200;
CGPoint swerveSnapPoint = self.swerveButton.center;
CGPoint followSnapPoint = self.followButton.center;
UISnapBehavior *followSnap = [[UISnapBehavior alloc] initWithItem:self.followButton
snapToPoint:followSnapPoint];
UISnapBehavior *swerveSnap = [[UISnapBehavior alloc] initWithItem:self.swerveButton
snapToPoint:swerveSnapPoint];
[self.overlayView fadeInWithDuration:0.2 completion:^{
swerveSnap.damping = 0.3;
[self.animator addBehavior:swerveSnap];
followSnap.damping = 0.3;
[self.animator addBehavior:followSnap];
}];
}发布于 2014-08-07 00:49:36
UIKitDynamics不能与约束一起工作。如果你想使用它们,你将不得不走老路,手动设置帧,至少在动画过程中是这样。
https://stackoverflow.com/questions/25165694
复制相似问题