Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix statusBarHidden setting in iOS 14 #1

Merged
merged 1 commit into from
May 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ImageViewer/Source/GalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {
self.modalPresentationStyle = .overFullScreen
self.dataSource = pagingDataSource

UIApplication.applicationWindow.windowLevel = (statusBarHidden) ? UIWindow.Level.statusBar + 1 : UIWindow.Level.normal

NotificationCenter.default.addObserver(self, selector: #selector(GalleryViewController.rotate), name: UIDevice.orientationDidChangeNotification, object: nil)

if continueNextVideoOnFinish {
Expand All @@ -187,6 +185,9 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {
page(toIndex: currentIndex+1)
}

open override var prefersStatusBarHidden: Bool {
return statusBarHidden
}

fileprivate func configureOverlayView() {

Expand Down Expand Up @@ -248,6 +249,7 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {

open override func viewDidLoad() {
super.viewDidLoad()
modalPresentationCapturesStatusBarAppearance = true

if #available(iOS 11.0, *) {
if (statusBarHidden || UIScreen.hasNotch) {
Expand Down Expand Up @@ -280,7 +282,6 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {
}

fileprivate func presentInitially() {

isAnimating = true

///Animates decoration views to the initial state if they are set to be visible on launch. We do not need to do anything if they are set to be hidden because they are already set up as hidden by default. Unhiding them for the launch is part of chosen UX.
Expand Down Expand Up @@ -549,14 +550,14 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {

/// Invoked when closed programmatically
open func close() {

closeDecorationViews(programmaticallyClosedCompletion)
setNeedsStatusBarAppearanceUpdate()
}

/// Invoked when closed via close button
@objc fileprivate func closeInteractively() {

closeDecorationViews(closedCompletion)
setNeedsStatusBarAppearanceUpdate()
}

fileprivate func closeDecorationViews(_ completion: (() -> Void)?) {
Expand Down