我有一个带有 Alpha 属性的简单 UIButton,我想将其从 1.0f 设置为 0.0f,然后再返回 1.0f。这基本上是对 TouchDown 的响应。
另外,如果我调用的例程不在主线程上(在线程池上调用的异步委托),我需要做什么特别的事情吗?
我应该使用 CAAnimation 吗?
Thanks!
除非有人用单声道方式来做到这一点,否则我说使用:
- (void) pulseButton {
button.alpha = 0.0;
[UIView beginAnimations:nil context:button]; {
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(makeVisibleAgain:finished:context:)];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.50];
button.alpha = 0.0;
} [UIView commitAnimations];
}
- (void)makeVisibleAgain:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
UIButton *button = ((UIButton *) context);
[UIView beginAnimations:nil context:nil]; {
[UIView setAnimationDelegate:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.5];
button.alpha = 1.0;
} [UIView commitAnimations];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)