//
//  Copyright © 2017 Carousell. All rights reserved.
//

import UIKit

internal final class SlideUpPresentationController: UIPresentationController {

    override func presentationTransitionWillBegin() {
        adjustContainerFrame()
    }

    // MARK: - UITraitEnvironment

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        if previousTraitCollection != nil {
            // Update the frame for the container view after device rotation.
            adjustContainerFrame()
        }
    }

    // MARK: - Private

    private func adjustContainerFrame() {
        // Calculate the presented frame that doesn't cover the navigation bar.
        let targetFrame: CGRect

        if let navigationBar = presentingViewController.view.subviews.filter({ $0 is UINavigationBar }).first {
            targetFrame = presentingViewController.view.frame.divided(atDistance: navigationBar.frame.maxY, from: .minYEdge).remainder
        } else {
            targetFrame = presentingViewController.view.frame
        }

        containerView?.frame = targetFrame
    }

}

//
//  Copyright © 2017 Carousell. All rights reserved.
//

import UIKit

internal final class SlideUpPresentationController: UIPresentationController {

    override func presentationTransitionWillBegin() {
        // Calculate the presented frame that doesn't cover the navigation bar.
        let targetFrame: CGRect

        if let navigationBar = presentingViewController.view.subviews.filter({ $0 is UINavigationBar }).first {
            targetFrame = presentingViewController.view.frame.divided(atDistance: navigationBar.frame.maxY, from: .minYEdge).remainder
        } else {
            targetFrame = presentingViewController.view.frame
        }

        containerView?.frame = targetFrame
    }

}

--- 
+++ 
@@ -7,6 +7,21 @@
 internal final class SlideUpPresentationController: UIPresentationController {
 
     override func presentationTransitionWillBegin() {
+        adjustContainerFrame()
+    }
+
+    // MARK: - UITraitEnvironment
+
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        if previousTraitCollection != nil {
+            // Update the frame for the container view after device rotation.
+            adjustContainerFrame()
+        }
+    }
+
+    // MARK: - Private
+
+    private func adjustContainerFrame() {
         // Calculate the presented frame that doesn't cover the navigation bar.
         let targetFrame: CGRect
 
Update the container frame for photo albums after device rotation
