From f09bd80e694ad8a2650ed65bdf05d55c5d16d090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Wed, 24 Dec 2014 02:43:35 +0100 Subject: [PATCH] added automatic dark mode for light status bar (likely to go along with dark navigation bar) --- src/Blur/MRBlurView.m | 10 +++++++++- src/Components/MRProgressOverlayView.m | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Blur/MRBlurView.m b/src/Blur/MRBlurView.m index 5b72b6d..c409bfb 100644 --- a/src/Blur/MRBlurView.m +++ b/src/Blur/MRBlurView.m @@ -103,6 +103,10 @@ - (void)statusBarOrientationDidChange:(NSNotification *)notification { - (void)setPlaceholder { self.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.96]; + + if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) { + self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.96]; + } } - (void)clearPlaceholder { @@ -126,7 +130,11 @@ - (void)redraw { } dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - image = [image mr_applyBlurWithRadius:30.0 tintColor:[UIColor colorWithWhite:0.97 alpha:0.82] saturationDeltaFactor:1.0 maskImage:nil]; + UIColor *defaultBgColor = [UIColor colorWithWhite:0.97 alpha:0.82]; + if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) { + defaultBgColor = [UIColor colorWithWhite:0.03 alpha:0.82]; + } + image = [image mr_applyBlurWithRadius:30.0 tintColor:defaultBgColor saturationDeltaFactor:1.0 maskImage:nil]; dispatch_async(dispatch_get_main_queue(), ^{ // Fade on content's change, dependent if there was already an image. CATransition *transition = [CATransition new]; diff --git a/src/Components/MRProgressOverlayView.m b/src/Components/MRProgressOverlayView.m index d20b482..c8b3db7 100644 --- a/src/Components/MRProgressOverlayView.m +++ b/src/Components/MRProgressOverlayView.m @@ -196,8 +196,12 @@ - (void)commonInit { // Create titleLabel UILabel *titleLabel = [UILabel new]; self.titleLabel = titleLabel; + UIColor *textColor = UIColor.blackColor; + if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) { + textColor = UIColor.whiteColor; + } self.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Loading ..." attributes:@{ - NSForegroundColorAttributeName: UIColor.blackColor, + NSForegroundColorAttributeName: textColor, NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline], NSKernAttributeName: NSNull.null, // turn on auto-kerning }]; @@ -566,7 +570,12 @@ - (void)show:(BOOL)animated { void(^animBlock)() = ^{ [self setSubviewTransform:CGAffineTransformIdentity alpha:1.0f]; - self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f]; + if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) { + self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.4f]; + } else { + self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f]; + } + }; if (animated) {