Просмотр исходного кода

Fix status bar styling for apps that use global status bar management.

Ryan Olson лет назад: 12
Родитель
Сommit
5be95ddd95
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      Classes/Explorer Toolbar/FLEXExplorerViewController.m

+ 21 - 0
Classes/Explorer Toolbar/FLEXExplorerViewController.m

@@ -58,6 +58,12 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
 /// If we're just showing the toolbar, we want the main app's window to remain key so that we don't interfere with input, status bar, etc.
 /// If we're just showing the toolbar, we want the main app's window to remain key so that we don't interfere with input, status bar, etc.
 @property (nonatomic, strong) UIWindow *previousKeyWindow;
 @property (nonatomic, strong) UIWindow *previousKeyWindow;
 
 
+/// Similar to the previousKeyWindow property above, we need to track status bar styling if
+/// the app doesn't use view controller based status bar management. When we present a modal,
+/// we want to change the status bar style to UIStausBarStyleDefault. Before changing, we stash
+/// the current style. On dismissal, we return the staus bar to the style that the app was using previously.
+@property (nonatomic, assign) UIStatusBarStyle previousStatusBarStyle;
+
 /// All views that we're KVOing. Used to help us clean up properly.
 /// All views that we're KVOing. Used to help us clean up properly.
 @property (nonatomic, strong) NSMutableSet *observedViews;
 @property (nonatomic, strong) NSMutableSet *observedViews;
 
 
@@ -821,6 +827,15 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     // Move the status bar on top of FLEX so we can get scroll to top behavior for taps.
     // Move the status bar on top of FLEX so we can get scroll to top behavior for taps.
     [[self statusWindow] setWindowLevel:self.view.window.windowLevel + 1.0];
     [[self statusWindow] setWindowLevel:self.view.window.windowLevel + 1.0];
     
     
+    // If this app doesn't use view controller based status bar management and we're on iOS 7+,
+    // make sure the status bar style is UIStatusBarStyleDefault. We don't actully have to check
+    // for view controller based management because the global methods no-op if that is turned on.
+    // Only for iOS 7+
+    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
+        self.previousStatusBarStyle = [[UIApplication sharedApplication] statusBarStyle];
+        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
+    }
+    
     // Show the view controller.
     // Show the view controller.
     [self presentViewController:viewController animated:animated completion:completion];
     [self presentViewController:viewController animated:animated completion:completion];
 }
 }
@@ -835,6 +850,12 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
     // We want it above FLEX while a modal is presented for scroll to top, but below FLEX otherwise for exploration.
     // We want it above FLEX while a modal is presented for scroll to top, but below FLEX otherwise for exploration.
     [[self statusWindow] setWindowLevel:UIWindowLevelStatusBar];
     [[self statusWindow] setWindowLevel:UIWindowLevelStatusBar];
     
     
+    // Restore the stauts bar style if the app is using global status bar management.
+    // Only for iOS 7+
+    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
+        [[UIApplication sharedApplication] setStatusBarStyle:self.previousStatusBarStyle];
+    }
+    
     [self dismissViewControllerAnimated:animated completion:completion];
     [self dismissViewControllerAnimated:animated completion:completion];
 }
 }