1

I would like to animate placeholder text color in UISearchBar.

So I would like to have placeholder text going from gray to green and back to gray in 1 second and repeat for 8 times.

With help from comment I tried :

[UIView transitionWithView:self.searchBar duration:1.0 options:UIViewAnimationOptionRepeat animations:^{
        [UIView setAnimationRepeatCount:8];
        [self.searchBar setValue:[UIColor greenColor] forKeyPath:@"_searchField._placeholderLabel.textColor"];
} completion:nil];

I added this code in viewDidAppear method.

But the problem is that the animation still does not work. It only changes the color of placeholder text without animation.

It only works with UIViewAnimationOptionTransitionCrossDissolve but I don't want that effect.

Any ideas?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Matic1911
  • 381
  • 1
  • 3
  • 13
  • Possible duplicate of [How to animate the textColor property of an UILabel?](http://stackoverflow.com/questions/2426614/how-to-animate-the-textcolor-property-of-an-uilabel) – akashivskyy Nov 15 '15 at 12:14
  • Thank you for help. Yes it works, but not the way I want it to work. Please se my updated version of the question. – Matic1911 Nov 15 '15 at 12:49

0 Answers0