2009-02-25 144 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