MBProgressHud with gif image

前端 未结 4 767
傲寒
傲寒 2021-02-11 01:48

Can I use gif image instead of default loading indicator? I am using this code so far but not getting any result. Can anyone suggest what is wrong in this code?



        
4条回答
  •  花落未央
    2021-02-11 02:36

    Yes, you can use gif images instead of default loading...

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.label.text = @"loading…";
    hud.mode = MBProgressHUDModeCustomView;
    UIImage *image = [[UIImage imageNamed:@"toast_loading"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    anima.toValue = http://www.cnblogs.com/Apologize/p/@(M_PI*2);
    anima.duration = 1.0f;
    anima.repeatCount = 10;
    [imgView.layer addAnimation:anima forKey:nil];
    hud.customView = imgView;
    
    hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:1];
    // text color
    hud.contentColor = [UIColor whiteColor];
    hud.animationType = MBProgressHUDAnimationFade;
    

提交回复
热议问题