开发者

Changing UILabel over time?

开发者 https://www.devze.com 2022-12-29 22:26 出处:网络
I have a simple UILabel on that I want to change the text of e开发者_C百科very 10 seconds. What is the best way of doing this, which let\'s the rest of the interface remain active?NSTimer *timer = [NS

I have a simple UILabel on that I want to change the text of e开发者_C百科very 10 seconds. What is the best way of doing this, which let's the rest of the interface remain active?


NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0f target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES];
self.repeatingTimer = timer;
...

- (void) updateLabel:(id)sender {
    myLabel.text = newStringValue;
}

...
[repeatingTimer invalidate];
self.repeatingTimer = nil; // stops timer


All you need is to start an NSTimer and update the label.text each time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号