我正在尝试使用 UIView
动画将 View 简单地移动到屏幕上:
[UIView animateWithDuration:.10 delay:0 options: nil animations:^
{
self.menusView.frame = endingMenuViewFrame;;
}
completion:^(BOOL finished)
{
}];
我想添加一个动画,以便 UIView 在它下降之前到达顶部时漂浮一点,即类似于如果有人在空中跳跃 - 当他们第一次跳跃时,他们会快速向上弹起,然后重力当他们到达跳跃的顶点时,逐渐减慢他们的速度,并最终将他们推回地面。有谁知道如何做到这一点?
最佳答案
试试这个代码。每次你的高度减少一半时,这将使你的 View 反弹三次。您可以添加更多退回邮件。
CGFloat offset = 200.0;
CGRect originalFrame = self.menusView.frame;
[UIView animateWithDuration:1.0 animations:^{
CGRect frame = self.runnerAlertView.frame;
frame.origin.y = frame.origin.y - offset;
self.menusView.frame = frame;
} completion:^(BOOL finished){
[UIView animateWithDuration:1.0 animations:^{
self.menusView.frame = originalFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:1.0 animations:^{
CGRect frame = self.menusView.frame;
frame.origin.y = frame.origin.y - 0.5 *offset;
self.menusView.frame = frame;
} completion:^(BOOL finished){
[UIView animateWithDuration:1.0 animations:^{
self.menusView.frame = originalFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:1.0 animations:^{
CGRect frame = self.runnerAlertView.frame;
frame.origin.y = frame.origin.y - 0.25 * offset;
self.menusView.frame = frame;
} completion:^(BOOL finished){
[UIView animateWithDuration:1.0 animations:^{
self.menusView.frame = originalFrame;
}];
}];
}];
}];
}];
}];
关于ios - UIView动画: simulating velocity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19613139/