我可以使用gif圖像而不是默認加載嗎?我到目前爲止使用此代碼,但沒有得到任何結果。任何人都可以提出這個代碼有什麼問題嗎?MBProgreeHud與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];
}
檢查:https://www.cocoacontrols.com/controls/gifprogresshud –
@AntonyRaphel檢查了這一點。我想知道我可以使用MBProgressHUD來實現這個功能嗎? – Niharika
代碼添加爲ans –