本案例实现的是 数据加载时的状态显示。
首先建立UIView
UIView *loadingView; //显示加载状态图标 - (void)showDial{ if ([[self.window subviews] indexOfObject:loadingView] != NSNotFound) { [self.window bringSubviewToFront:loadingView]; }else { [self.window addSubview:loadingView]; [self.window bringSubviewToFront:loadingView]; } //不允许用户输入 self.window.userInteractionEnabled = NO; }
- (void)hideDial{ if ([[self.window subviews] indexOfObject:loadingView] != NSNotFound) { [loadingView removeFromSuperview]; } //允许用户输入 self.window.userInteractionEnabled = YES; } |