Reputation: 24718
I infer from this question that the following should animate the colour change of my UITextField's border:
[UIView animateWithDuration:5.0f animations:^() {
myUITextField.layer.borderColor = [UIColor greenColor].CGColor;
}];
But it doesn't, the border changes colour instantly. Is it obvious what I'm doing wrong?
Update: Ok, so trying the following implicit animation:
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:5.0f] forKey:kCATransactionAnimationDuration];
myUITextField.layer.borderColor = [UIColor greenColor].CGColor;
[CATransaction commit];
And that doesn't animate either, same effect: it changes colour instantly (as an aside, where's the default for kCATransactionAnimationDuration for layer.borderColor documented?)
Upvotes: 2
Views: 3209
Reputation: 135588
I believe that CALayer
properties are not animatable in a UIView
animation block. You would need to set up a CABasicAnimation
and add that animation to the layer instead.
Upvotes: 6