苹果的应用程序一般都会用一种优雅的、半透明的进度显示效果。不过这个API是不公开的,因此你要是用了,很可能被清除出AppStore。而 MBProgressHUD提供了一个替代方案,而且在用户角度上,实现的效果根本看不出和官方程序有什么差别。

默认使用的系统自带指示器
自定义MBProgressHUD:
-(void)showProgressHUD:(UIView *)view{
//默认系统自带的指示器ProgressHUD
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
// hud.labelText = @"正在加载……";
//自定义的ProgressHUD
UIImageView *animationImageView = [[UIImageView alloc] init];
animationImageView.frame = CGRectMake(0, 0, 64, 64);
//hud的动画图片数组
NSMutableArray *imageArray = [NSMutableArray array];
for (int i = 0; i < 51; i++) {
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"PR_3_000%d.png",i]]];
}
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
hud.color = [UIColor clearColor];
//hud的动画效果
hud.customView = animationImageView;
animationImageView.animationImages = imageArray;
animationImageView.animationDuration = 1.5;
animationImageView.animationRepeatCount = 0;
[animationImageView startAnimating];
}
效果图: