1

不知道如何描述这一点,但是让 UILabel 显示 Loading,然后 Loading.,然后 Loading..,然后 Loading...,然后重复的最简单方法是什么?

我一直在研究计时器,但这似乎有点过分了。任何人都知道一个很酷且快速的技巧来完成这样的事情吗?谢谢!

4

1 回答 1

7

Not sure about your specific use case (more info please or code?) but have you tried animation blocks? Something like:

- (void)animate
{
    __block UIView * blockSelf = self;

    [UIView animateWithDuration:0.1f animations:^{
        if ([blockSelf.label.text isEqualToString:@"Loading..."]) {
            blockSelf.label.text = @"Loading";
        } else {
            blockSelf.label.text = [NSString stringWithFormat:@"%@.", blockSelf.label.text];
        }
    } completion:^(BOOL finished) {
        if (blockSelf.processIsFinished) {
            [self moveOn];
        } else {
            [blockSelf animate];
        }
    }];
}

Alternatively, something like MBProgressHUD might be useful depending on what type of process is "loading".

于 2013-08-01T15:58:02.023 回答