我正在尝试为下面的动画添加一个反弹效果。这是我的代码:
[UIView animateWithDuration:1.0
delay:.0
usingSpringWithDamping:0.5
initialSpringVelocity:2.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
// Coming from a value of CGAffineTransformMakeScale(0.001, 1.0)
self.myView.transform = CGAffineTransformMakeScale(1.0, 1.0);
}completion:nil
];
它无法正常工作。它在动画结束时变宽,然后恢复正常。我希望宽度反弹到小于1.0的值,不超过1.0。
答案 0 :(得分:8)
用于将来的代码重用和保持代码清洁
popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
[self.view addSubview:popUp];
[UIView animateWithDuration:0.3/1.5 animations:^{
popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
popUp.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
popUp.transform = CGAffineTransformIdentity;
}];
}];
}];
答案 1 :(得分:2)
这篇文章给出了UIView反弹动画的详细解释,包括UIDynamicAnimator和spring Animation