jdg / MBProgressHUD

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

Incorrect layouts order #516

Closed brightsider closed 5 years ago

brightsider commented 6 years ago

I'm add MBProgressHUD and after changing blurEffectStyle layouts stacked in incorrect order

MBProgressHUD *currentProgress = [[MBProgressHUD alloc] initWithView:view]; currentProgress.bezelView.blurEffectStyle = UIBlurEffectStyleDark; currentProgress.backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2]; currentProgress.removeFromSuperViewOnHide = YES; [view addSubview:currentProgress]; [currentProgress showAnimated:YES];

hud

daurenm commented 6 years ago

I got it working by setting blurEffectStyle through MBProgressHUD.appearance()

brightsider commented 6 years ago

And how you change blurEffectStyle through appearance? I don't see this functionality in code.

davidloveengles commented 6 years ago

hud.label.superview?.subviews.forEach({ (view) in if view is UIVisualEffectView { let blur = UIBlurEffect(style: UIBlurEffectStyle.dark) (view as! UIVisualEffectView).effect = blur } })

(this is my way to solve this bug).

yueno12 commented 6 years ago

+1

tipa commented 6 years ago

+1

matej commented 5 years ago

Fixed by https://github.com/jdg/MBProgressHUD/pull/525 and added a regression test.

mikeooye commented 5 years ago
extension MBBackgroundView {
  private func getEffectView() -> UIVisualEffectView? {
    for view in subviews {
      if let effectView = view as? UIVisualEffectView {
        return effectView
      }
    }
    return nil
  }

  func updateBlurEffect(style: UIBlurEffect.Style) {
    getEffectView()?.removeFromSuperview()
    blurEffectStyle = style
    if let blurView = getEffectView() {
      sendSubviewToBack(blurView)
    }
  }
}