【发布时间】:2013-07-11 16:24:25
【问题描述】:
我在 UITextField 上创建了一个类别,它允许在红色和白色之间进行动画处理,如下所示:
@implementation UITextField (Additions)
-(void) flash
{
[UIView animateWithDuration:2.0 animations:^{
[self setBackgroundColor:[UIColor redColor]];
} completion:^(BOOL finished) {
[self setBackgroundColor:[UIColor whiteColor]];
}];
}
@end
我这样称呼它:
[self.paymentTextField flash];
第一次工作时,它显示红色背景,然后切换回白色。但是在第二次调用时它什么也没做。
【问题讨论】:
-
看起来并不像看起来那么容易:stackoverflow.com/questions/3944416/… 您可以通过在文本字段顶部创建一个红色 UIView 并为其 alpha 设置动画来解决问题。
标签: ios cocoa-touch uitextfield