已经做成通用函数
// 显示
// tag自己要记住,用于隐藏
void wiShowWaitingView(UIView *parentview, NSString *text, NSInteger tag)
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
[view setBackgroundColor:[UIColor clearColor]];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 150, 200, 120)];
[imageView setImage:[UIImage imageNamed:@"login_block"]]; // 图片自己定义
UIActivityIndicatorView *progressInd = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
progressInd.center = CGPointMake(parentview.center.x, 190);
[progressInd startAnimating];
UILabel *waitingLable = [[UILabel alloc] initWithFrame:CGRectMake(60, 220, 200, 25)];
waitingLable.text = text;
waitingLable.textAlignment = UITextAlignmentCenter;
waitingLable.textColor = [UIColor darkGrayColor];
waitingLable.font = [UIFont systemFontOfSize:15];
waitingLable.backgroundColor = [UIColor clearColor];
[view addSubview:imageView];
[view addSubview:progressInd];
[view addSubview:waitingLable];
[imageView release];
[progressInd release];
[waitingLable release];
view.tag = tag;
[parentview addSubview:view];
[view release];
}
// 隐藏
void wiHideWaitingView(UIView *parentview, NSInteger tag)
{
[[parentview viewWithTag:tag] removeFromSuperview];
}