UIActivityIndicatorView *_aiView; //用来加载动画 UIButton *_clickMask; //button //加载动画 -(void)loginAnimationActivityIndicatorView { _clickMask = [UIButton buttonWithType:UIButtonTypeCustom]; [_clickMask setFrame:[UIScreen mainScreen].bounds]; [self.view addSubview:_clickMask]; [_clickMask setHidden:YES];//隐藏按钮 _aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; //[aiView setBackgroundColor:[UIColor grayColor]]; _aiView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/2 - 45/2, [UIScreen mainScreen].bounds.size.height/2 - 45/2+120, 45, 45); _aiView.hidesWhenStopped = YES; [self.view addSubview:[_aiView autorelease]]; [_aiView stopAnimating]; } //是否隐藏AnimationActivityIndicatorView -(void)waitView:(BOOL)want2Show { if (want2Show) { [self.view bringSubviewToFront:_clickMask]; [self.view bringSubviewToFront:_aiView]; [_clickMask setHidden:NO]; [_aiView startAnimating]; }else { [_clickMask setHidden:YES]; [_aiView stopAnimating]; } }