iOS MBProgressHUD自定义动画
2017-01-24 本文已影响471人
XieHenry
最近在做公司的新需求,其中一项是自定义刷新数据时的git动画,在此记录一下,方便以后自己使用。
需求如下:
需求图.png自定义这个方法即可:
+(MBProgressHUD *)showLoading:(UIView *)view title:(NSString *)title{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view==nil?[[UIApplication sharedApplication].windows lastObject]:view animated:YES];
hud.mode = MBProgressHUDModeCustomView;
// hud.minSize = CGSizeMake(165,90);//定义弹窗的大小
UIImage *image = [[UIImage imageNamed:@"loading_pic_0"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView* mainImageView= [[UIImageView alloc] initWithImage:image];
mainImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"loading_pic_0"],
[UIImage imageNamed:@"loading_pic_1"],
[UIImage imageNamed:@"loading_pic_2"],[UIImage imageNamed:@"loading_pic_3"],nil];
[mainImageView setAnimationDuration:0.5f];
[mainImageView setAnimationRepeatCount:0];
[mainImageView startAnimating];
hud.customView = mainImageView;
hud.animationType = MBProgressHUDAnimationFade;
return hud;
}