From 42b46fb110f141f842b14438208039915c0f4673 Mon Sep 17 00:00:00 2001 From: Johannes Eichler Date: Wed, 20 Sep 2017 18:38:18 +0200 Subject: [PATCH 1/2] On iOS 11 there is an assertion failure when addSubview is called directly on a UIVisualEffectView. In this case subviews should be added to the contentView. Since hudView can be both I have added a quick check for this. --- HTProgressHUD/HTProgressHUD.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/HTProgressHUD/HTProgressHUD.m b/HTProgressHUD/HTProgressHUD.m index 61dc9de..430751f 100755 --- a/HTProgressHUD/HTProgressHUD.m +++ b/HTProgressHUD/HTProgressHUD.m @@ -239,7 +239,14 @@ - (instancetype)initWithFrame:(CGRect)frame self.textLabel.textAlignment = NSTextAlignmentCenter; self.textLabel.font = [UIFont boldSystemFontOfSize:14.0f]; self.textLabel.numberOfLines = 1; - [self.hudView addSubview:self.textLabel]; + if([self.hudView isKindOfClass:[UIVisualEffectView class]]) + { + [((UIVisualEffectView *)self.hudView).contentView addSubview:self.textLabel]; + } + else + { + [self.hudView addSubview:self.textLabel]; + } // Appearance Options self.indicatorView = [HTProgressHUDIndicatorView indicatorViewWithType:HTProgressHUDIndicatorTypeActivityIndicator]; @@ -513,6 +520,14 @@ - (void)setIndicatorView:(HTProgressHUDIndicatorView *)indicatorView { [_indicatorView removeFromSuperview]; _indicatorView = indicatorView; + if([self.hudView isKindOfClass:[UIVisualEffectView class]]) + { + [((UIVisualEffectView *)self.hudView).contentView addSubview:indicatorView]; + } + else + { + [self.hudView addSubview:indicatorView]; + } [self.hudView addSubview:indicatorView]; [self updateViews]; } From fb854603cf405cfafe34c6d5c960c1549fbe06a6 Mon Sep 17 00:00:00 2001 From: Johannes Eichler Date: Wed, 20 Sep 2017 18:42:46 +0200 Subject: [PATCH 2/2] Removed duplicate call to addSubview --- HTProgressHUD/HTProgressHUD.m | 1 - 1 file changed, 1 deletion(-) diff --git a/HTProgressHUD/HTProgressHUD.m b/HTProgressHUD/HTProgressHUD.m index 430751f..6eb5d5f 100755 --- a/HTProgressHUD/HTProgressHUD.m +++ b/HTProgressHUD/HTProgressHUD.m @@ -528,7 +528,6 @@ - (void)setIndicatorView:(HTProgressHUDIndicatorView *)indicatorView { [self.hudView addSubview:indicatorView]; } - [self.hudView addSubview:indicatorView]; [self updateViews]; }