【发布时间】:2018-09-26 18:29:28
【问题描述】:
我可以使用 gif 图像代替默认加载指示器吗?到目前为止,我正在使用此代码,但没有得到任何结果。谁能建议这段代码有什么问题?
#import "UIImage+GIF.h"
-(void) showLoadingHUD:(NSString *)title
{
[self hideLoadingHUD];
if(!HUD){
HUD = [MBProgressHUD showHUDAddedTo:self.window animated:YES];
}
[HUD setColor:[UIColor clearColor]];
UIImageView *imageViewAnimatedGif = [[UIImageView alloc]init];
imageViewAnimatedGif.image= [UIImage sd_animatedGIFNamed:@"martini_glass"];
HUD.customView = [[UIImageView alloc] initWithImage:imageViewAnimatedGif.image];
CABasicAnimation *rotation;
rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotation.fromValue = [NSNumber numberWithFloat:0];
rotation.toValue = [NSNumber numberWithFloat:(2 * M_PI)];
rotation.duration = 0.7f; // Speed
rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number.
[HUD.customView.layer addAnimation:rotation forKey:@"Spin"];
HUD.mode = MBProgressHUDModeCustomView;
[HUD show:YES];
}
【问题讨论】:
-
@AntonyRapel 检查了这个。我想知道我可以使用 MBProgressHUD 来实现它吗?
-
作为ans添加的代码
-
@AntonyRapel 谢谢.. 它有效!!!!!
-
不客气!!
标签: ios objective-c animated-gif mbprogresshud