UILabel 上的闪烁效果 [英] Blinking effect on UILabel

查看:24
本文介绍了UILabel 上的闪烁效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个背景颜色为灰色的 UILabel.

I have a UILabel with background color as grey.

我想在这个标签上有一个闪烁的效果,就像它应该变得有点白&然后变成灰色,它应该一直发生,直到我以编程方式将其关闭.

I want a blinking effect on this label like it should become a little white & then become gray and it should keep happen till I turn it off programatically.

知道如何实现这一目标吗?

Any clue how to achieve this?

推荐答案

使用 NSTimer

NSTimer *timer = [NSTimer 
                      scheduledTimerWithTimeInterval:(NSTimeInterval)(1.0)
                            target:self 
                             selector:@selector(blink) 
                             userInfo:nil 
                             repeats:TRUE];
BOOL blinkStatus = NO;

在你的眨眼功能中

-(void)blink{
   if(blinkStatus == NO){
      yourLabel.backgroundColor = [UIColor whiteColor];
     blinkStatus = YES;
   }else {
      yourLabel.backgroundColor = [UIColor grayColor];
      blinkStatus = NO;
   }
}

这篇关于UILabel 上的闪烁效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆