对UILabel的闪烁效果 [英] Blinking effect on UILabel
本文介绍了对UILabel的闪烁效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个背景颜色为UILabel的灰色。
我想要一个闪烁的效果,这个标签应该成为一个小白色&然后变成灰色,它应该继续发生,直到我把它关闭程序。
任何线索如何实现这一点?
解决方案
c $ c> 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;
}
}
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?
解决方案Use
NSTimer
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(1.0) target:self selector:@selector(blink) userInfo:nil repeats:TRUE]; BOOL blinkStatus = NO;
in your blink function
-(void)blink{ if(blinkStatus == NO){ yourLabel.backgroundColor = [UIColor whiteColor]; blinkStatus = YES; }else { yourLabel.backgroundColor = [UIColor grayColor]; blinkStatus = NO; } }
这篇关于对UILabel的闪烁效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文