MBProgressHud with gif image

前端 未结 4 1874
栀梦
栀梦 2021-02-11 01:46

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:32

    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;
    

提交回复
热议问题