diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift index 4c810c42b6..5578e6234a 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift @@ -44,6 +44,7 @@ class GalleryItemViewController: UIViewController { private(set) var scrollAndZoomEnabled = true private var scrollViewSizeForLastZoomScaleUpdate: CGSize? + override var prefersHomeIndicatorAutoHidden: Bool { return !controlsVisible } @@ -227,6 +228,8 @@ class GalleryItemViewController: UIViewController { updateZoomScale(resetZoom: true) } centerContent() + // Ensure the transform is correct if the controls are hidden and their size changed. + setControlsVisible(controlsVisible, animated: false) } override func viewDidAppear(_ animated: Bool) { @@ -289,10 +292,12 @@ class GalleryItemViewController: UIViewController { func setControlsVisible(_ visible: Bool, animated: Bool) { controlsVisible = visible + guard let topControlsView, let bottomControlsView else { return } + func updateControlsViews() { topControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : -topControlsView.bounds.height) bottomControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : bottomControlsView.bounds.height) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift index 6131f73ccd..e53e90ea9a 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift @@ -125,6 +125,8 @@ extension GalleryViewController: UIPageViewControllerDataSource { extension GalleryViewController: UIPageViewControllerDelegate { public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) { currentItemViewController.content.galleryContentWillDisappear() + let new = pendingViewControllers[0] as! GalleryItemViewController + new.setControlsVisible(currentItemViewController.controlsVisible, animated: false) } public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {