Hi all,
I have a UILabel and when the value change in the label, I want to highlight it's background color from another color and exists for 2,3 seconds and get back to normal color.
Anyone have an idea how to do this?
Hi all,
I have a UILabel and when the value change in the label, I want to highlight it's background color from another color and exists for 2,3 seconds and get back to normal color.
Anyone have an idea how to do this?
Use this code
- (void) initController
{
UIButton *myButton = [view viewWithTag:1]; // Just reference the button you have
[myButton addTarget:self action:@selector(animateLabel) forControlEvents:UIControlEventTouchUpInside];
}
- (void) animateLabel
{
CABasicAnimation* highlightAnim = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
highlightAnim.toValue = (id)[UIColor blueColor].CGColor;
highlightAnim.duration = 2; // In seconds
highlightAnim.autoreverses = YES; // If you want to it to return to the normal color
[label.layer addAnimation:highlightAnim forKey:nil];
}