iOS MBProgressHUD自定义动画

最近在做公司的新需求,其中一项是自定义刷新数据时的git动画,在此记录一下,方便以后自己使用。

需求如下:

iOS MBProgressHUD自定义动画_第1张图片
需求图.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;
}

你可能感兴趣的:(iOS MBProgressHUD自定义动画)