2009-02-25 139 views

回答

4

创建一个切换背景颜色的功能。

-(void) flashBackground 
{ 
    UIColor* color = _flashOn ? [UIColor colorRed] : [UIColor colorWhite]; 
    _textField.backgroundColor = color; 
    [_textField setNeedsDisplay]; 
    _flashOn = !_flashOn; 

} 

然后设置一个定时器调用这个函数

[NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(flashBackground) userInfo: nil repeats: NO]; 
+0

感谢。顺便说一下,它是redColor和whiteColor。我已经对此进行了多次闪烁......在NSTimer中重复布尔变量,闪烁次数为计数器。 – 4thSpace 2009-02-26 05:18:20