jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

on iOS13 customView is much lighter and flickers #596

Open hixfield opened 4 years ago

hixfield commented 4 years ago

I use the following code to briefly show a custom view with icon that fades away automatically:

    func displayFading(icon: MessageIcon, title: String, delay: TimeInterval = 2.0, completion: (()->())? = nil) {
        let hud = MBProgressHUD.showAdded(to: view, animated: true)
        hud.mode = .customView
        hud.bezelView.backgroundColor = PaintCode.mainRed
        hud.contentColor = PaintCode.mainWhite
        hud.customView = UIImageView(image: icon.image.withRenderingMode(.alwaysTemplate))
        hud.isSquare = true
        hud.label.text = title
        hud.label.font = UIFont.defaultFont()
        hud.hide(animated: true, afterDelay: delay)
        hud.completionBlock = completion
    }

This has always worked on <iOS 13:

ios12.mov.zip

now in iOS 13 the view is much lighter the the desired (background) color. And if you pay attention initially is drawn correctly but a fraction of a second later the color is suddenly much lighter. Also when disappearing there is a brief flicker where the color is correct:

ios13.mov.zip

wonderffee commented 4 years ago

Maybe the same problem with me. It seems there is something wrong in this method:

@implementation MBBackgroundView
#pragma mark - Lifecycle

- (instancetype)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        _style = MBProgressHUDBackgroundStyleBlur;
        if (@available(iOS 13.0, *)) {
            #if TARGET_OS_TV
            _blurEffectStyle = UIBlurEffectStyleRegular;
            #else
            _blurEffectStyle = UIBlurEffectStyleSystemThickMaterial;
            #endif
            // Leaving the color unassigned yields best results.
        } else {
            _blurEffectStyle = UIBlurEffectStyleLight;
            _color = [UIColor colorWithWhite:0.8f alpha:0.6f];
        }

        self.clipsToBounds = YES;

        [self updateForBackgroundStyle];
    }
    return self;
}
@end

One solution is to change _blurEffectStyle = UIBlurEffectStyleSystemThickMaterial; to _blurEffectStyle = UIBlurEffectStyleLight;

Another solution is as follows(Objc): hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;