gpt4 book ai didi

ios - 如何给 UIView animateWithDuration 添加弹跳效果

转载 作者:可可西里 更新时间:2023-11-01 06:20:36 26 4
gpt4 key购买 nike

我正在尝试为下面的动画添加弹跳效果。这是我的代码:

[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。

最佳答案

为将来的代码重用和保持代码清洁

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;
}];
}];
}];

关于ios - 如何给 UIView animateWithDuration 添加弹跳效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069694/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com