可以通过这种方式自定义 SVProgressHUD 的 BG 颜色
-(void)showWithStatusSuccess
{
[[SVProgressHUD appearance] setHudBackgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.4]];
[[SVProgressHUD appearance] setHudForegroundColor:[UIColor yellowColor]];
[[SVProgressHUD appearance] setHudFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:16]];
[[SVProgressHUD appearance] setHudStatusShadowColor:[UIColor greenColor]];
[SVProgressHUD showSuccessWithStatus:@"Great Success!"];
}
-(void)showWithStatusError {
[[SVProgressHUD appearance] setHudBackgroundColor:[[UIColor redColor] colorWithAlphaComponent:0.4]];
//[[SVProgressHUD appearance] setHudForegroundColor:[UIColor yellowColor]];
[[SVProgressHUD appearance] setHudFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:16]];
//[[SVProgressHUD appearance] setHudStatusShadowColor:[UIColor greenColor]];
[SVProgressHUD showErrorWithStatus:@"Failed with Error"];
}
编辑:
在您的情况下,您需要在 showSuccessWithStatus 和 showErrorWithStatus Methods.so 中更改 SVProgressHUD 的 BGColor。所以转到 SVProgressHUD.m 文件更改您的代码
#pragma mark - Show then dismiss methods
+ (void)showSuccessWithStatus:(NSString *)string {
[[SVProgressHUD appearance] setHudBackgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.4]];
//[[SVProgressHUD appearance] setHudForegroundColor:[UIColor yellowColor]];
[[SVProgressHUD appearance] setHudFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:16]];
[self showImage:[[self sharedView] hudSuccessImage] status:string];
}
+ (void)showErrorWithStatus:(NSString *)string {
[[SVProgressHUD appearance] setHudBackgroundColor:[[UIColor redColor] colorWithAlphaComponent:0.4]];
//[[SVProgressHUD appearance] setHudForegroundColor:[UIColor yellowColor]];
[[SVProgressHUD appearance] setHudFont:[UIFont fontWithName:@"MarkerFelt-Wide" size:16]];
//[[SVProgressHUD appearance] setHudStatusShadowColor:[UIColor greenColor]];
//[SVProgressHUD showWithStatus:@"Error"];
[self showImage:[[self sharedView] hudErrorImage] status:string];
}
希望它对你有用。