简体   繁体   English

文本更改时如何为uitext标签设置动画?

[英]How to animate uitext label when there is a change in text?

I want to animate a text label when there is a change in it. 当文本标签发生变化时,我想设置文本标签的动画。 For ex, I got a price label which will be changed(dropped) regarding to the time. 例如,我得到了一个价格标签,该标签将随时间而变化(删除)。 If price is 100.25 and dropped to 100.24, I want to animate last digit. 如果价格为100.25,跌至100.24,我要设置最后一位数字的动画。

Is there a good animation library for the purpose I mention? 我是否有一个好的动画库供我提及?

Thanks 谢谢

Try this 尝试这个

You can use Fade effect 您可以使用淡入淡出效果

CATransition *animation = [CATransition animation];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.type = kCATransitionFade;
animation.duration = 0.75;
[aLabel.layer addAnimation:animation forKey:@"kCATransitionFade"];

// This will fade:
aLabel.text = xxx

Hope this helps. 希望这可以帮助。

//Try This One Hope So Helpful
  • (void)animateLabelShowText:(NSString*)newText characterDelay:(NSTimeInterval)delay { [self.myLabel setText:@""]; (void)animateLabelShowText:(NSString *)newText characterDelay:(NSTimeInterval)delay {[self.myLabel setText:@“”];

    for (int i=0; i 为(int i = 0; i

     [NSThread sleepForTimeInterval:delay]; 

    } } }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM