applidium/OverlayContainer

Is there a way to place a view on top of the overlay?

Closed this issue · 1 comments

I've been trying to place a floating action button that remains at the bottom of the screen no matter what overlay is presented, but I'm having a hard time figuring out the architecture required to do so. Is there any built in or suggested means of doing this?

If your overlay controller uses the flexibleHeight style (so if you havent a table view or a collection view), you can add the button right inside the overlay controller view hierarchy.

With the other styles, the button will move alongside the overlay motions. You can adjust it thanks to the container delegate callbacks. But you can also decide to create a container containing the overlay container and your extra floating view. Like so:

Your top container VC:

class StackViewController: UIViewController {
    var viewControllers: [UIViewController] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        viewControllers.forEach {
            addChild($0)
            subview.addSubview($0.view)
            $0.view.pinToSuperview()
            $0.didMove(toParent: self)
        }
    }
}

Your action view controller:

class FloatingActionViewController: UIViewController {

    override func loadView() {
        view = PassThroughView() // ⚠️
        let myButton = ...
        // ...
    }
}

Your final VC hierarchy:

let stack = StackViewController()
let overlayContainer = OverlayContainerViewController(...)
// container setup
let actionVC = FloatingActionViewController()
stack.viewControllers = [
    overlayContainer,
    actionVC
]
window.rootViewController = stack

Is it what you are looking for?