Making UITextField background blink
-
09-09-2019 - |
Question
How can I make the background color of a UITextField blink?
Solution
Create a function that toggles the the background color.
-(void) flashBackground
{
UIColor* color = _flashOn ? [UIColor colorRed] : [UIColor colorWhite];
_textField.backgroundColor = color;
[_textField setNeedsDisplay];
_flashOn = !_flashOn;
}
Then setup a timer to call this function
[NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(flashBackground) userInfo: nil repeats: NO];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow