diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-03-20 14:46:14 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2015-03-27 10:24:27 +0000 |
commit | ef9e742711a7a39932b73ad81dee7a9f0ae06a22 (patch) | |
tree | 680da0c2a01100e25f5c7ffb856bc0fe62869362 /src/plugins/platforms | |
parent | 013afc77f0a191ee60d0d2d6b84d35435fdc9c07 (diff) |
iOS: Update statusbar style based on MaximizeUsingFullscreenGeometryHint
When Qt::MaximizeUsingFullscreenGeometryHint is enabled for the focus
window we are likely to have window content under the statusbar, in
which case we revert to the default iOS statusbar style which is black
text. If this style doesn't fit the user application, the style can be
set in the Info.plist, or progammatically using native APIs, in
combination with UIViewControllerBasedStatusBarAppearance = NO.
Change-Id: I97576ae091bbfcb8718f980c25e91cc7ca605f03
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 30 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 971a474673..dffbf7dc27 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -45,6 +45,7 @@ class QIOSScreen; // UIViewController @property (nonatomic, assign) BOOL prefersStatusBarHidden; @property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation; +@property (nonatomic, assign) UIStatusBarStyle preferredStatusBarStyle; @end diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 9abd105d94..6667ec3dd8 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -245,6 +245,7 @@ // Status bar may be initially hidden at startup through Info.plist self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false); self.preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone; + self.preferredStatusBarStyle = UIStatusBarStyle(infoPlistValue(@"UIStatusBarStyle", UIStatusBarStyleDefault)); m_focusWindowChangeConnection = QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() { [self updateProperties]; @@ -423,6 +424,22 @@ UIApplication *uiApplication = [UIApplication sharedApplication]; + // -------------- Status bar style and visbility --------------- + + UIStatusBarStyle oldStatusBarStyle = self.preferredStatusBarStyle; + if (focusWindow->flags() & Qt::MaximizeUsingFullscreenGeometryHint) + self.preferredStatusBarStyle = UIStatusBarStyleDefault; + else + self.preferredStatusBarStyle = QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0 ? + UIStatusBarStyleLightContent : UIStatusBarStyleBlackTranslucent; + + if (self.preferredStatusBarStyle != oldStatusBarStyle) { + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) + [self setNeedsStatusBarAppearanceUpdate]; + else + [uiApplication setStatusBarStyle:self.preferredStatusBarStyle]; + } + bool currentStatusBarVisibility = self.prefersStatusBarHidden; self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen; @@ -484,18 +501,5 @@ } } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) -- (UIStatusBarStyle)preferredStatusBarStyle -{ - // Since we don't place anything behind the status bare by default, we - // end up with a black area, so we have to enable the white text mode - // of the iOS7 statusbar. - return UIStatusBarStyleLightContent; - - // FIXME: Try to detect the content underneath the statusbar and choose - // an appropriate style, and/or expose Qt APIs to control the style. -} -#endif - @end |