IOS:关于动画的问题
我有这个代码: successview 是我的视图,它以 alpha 0.00 开始,但是当它使用自动反转完成动画时,successview 变为 alpha 1.00...为什么?
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationRepeatAutoreverses:YES];
[successView setAlpha:1.00];
[UIView commitAnimations];
I have this code:
successview is my view and it start with alpha 0.00 but when it finish the animation with autoreverse, successview become with alpha 1.00...why?
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationRepeatAutoreverses:YES];
[successView setAlpha:1.00];
[UIView commitAnimations];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种方法是制作两种不同的动画:一种动画的 alpha 值逐渐变为 1.0,另一种动画从 1.0 回到 0。
使用
的 animateWithDuration:animations:completion:
方法UIView 来完成这个任务。您可以在完成块中执行相反的操作。类似的内容:
请参阅 UIView 文档以获取有关
One approach is to do two different animations: One that progresses towards an alpha value of 1.0 and then another that goes from 1.0 back to 0.
Use the
animateWithDuration:animations:completion:
method of theUIView
to accomplish this. You can do the reverse in the completion block.Something along the lines of:
See UIView documentation for more details on animations.
它在文档中:
更新:读取了错误的代码,但如果您的目标是 iOS 4.0 及更高版本,文档建议您使用
animateWithDuration:delay:options:animations:completion:
。It's in the docs:
Update: read wrong your code, but docs suggest that you use
animateWithDuration:delay:options:animations:completion:
instead if you are targeting iOS 4.0 and later.如果有人感兴趣,这里是 Swift 代码:
If someone is interested, here's Swift code: