我有这个代码: successview 是我的 View ,它以 alpha 0.00 开始,但是当它使用 autoreverse 完成动画时,successview 变为 alpha 1.00...为什么?
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationRepeatAutoreverses:YES];
[successView setAlpha:1.00];
[UIView commitAnimations];
最佳答案
一种方法是制作两种不同的动画:一种是朝着 alpha 值 1.0 前进,另一种是从 1.0 回到 0。
使用 UIView
的 animateWithDuration:animations:completion:
方法来完成此操作。您可以在完成 block 中执行相反的操作。
类似的东西:
[UIView animateWithDuration:0.2
animations:^{view.alpha = 1.0;}
completion:^(BOOL finished){
[UIView animateWithDuration:0.2
animations:^{view.alpha = 0;}];
}];
参见 UIView有关 animations 的更多详细信息的文档.
关于IOS:关于动画的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7001753/