如何动画更改UITextField的边框颜色

如何动画更改UITextField的边框颜色

本文介绍了如何动画更改UITextField的边框颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从:

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];

这也没有动画,效果相同:它立即改变颜色(顺便说一下,哪里有对于layer.borderColor记录的kCATransactionAnimationDuration的默认值是什么?)

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?)

推荐答案

我相信 CALayer c> UIView 动画块中的$ c>属性不可动画。您需要设置 CABasicAnimation 并将该动画添加到图层中。

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.

这篇关于如何动画更改UITextField的边框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 16:37