我有一个标签,我想淡入然后淡出.
这是我的代码:
这是我的代码:
-(void) fadein { scoreLabel.alpha = 0; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; [UIView setAnimationDuration:2]; scoreLabel.alpha = 1; [UIView commitAnimations]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; } -(void)animationDidStop:(Nsstring *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2]; scoreLabel.alpha = 0; [UIView commitAnimations]; }
解决方法
-(void) fadein { scoreLabel.alpha = 0; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; //don't forget to add delegate..... [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:2]; scoreLabel.alpha = 1; //also call this before commit animations...... [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; [UIView commitAnimations]; } -(void)animationDidStop:(Nsstring *)animationID finished:(NSNumber *)finished context:(void *)context { { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2]; scoreLabel.alpha = 0; [UIView commitAnimations]; }
原文地址:https://www.jb51.cc/c/114128.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。