0

我正在为 iOs 在 xcode 中编写应用程序。我有这样的代码:

- (void)buttonAction:(UIButton*)sender{

    UIView *figure = (UIView *) [figures objectAtIndex:sender.tag];

    [figure.layer setBorderWidth:2.0f];
    [figure.layer setBorderColor: [UIColor greenColor].CGColor];
    sleep(1);
    [self cleanScreen];

}

- (void) cleanScreen {

    //Some code to hide all view objects

}

我希望在 cleanScreen 函数删除项目之前,边框颜色和宽度的更改会在屏幕上反映 1 秒钟。但是碰巧这些更改没有反映,并且花了一秒钟的时间将元素删除。

我想在调用 cleanScreen 之前刷新屏幕。

如何达到我想要的效果?

提前致谢!

4

1 回答 1

3

代替:

sleep(1);

采用:

[self performSelector:@selector(cleanScreen) withObject:nil afterDelay:1];

sleep()您一起冻结整个应用程序

于 2012-12-11T20:00:20.097 回答