Skip to content

OverlayViewController is not layout before animation when set before moveOverlay(toNotchAt:animated:) #49

@denisPoifol

Description

@denisPoifol

When setting the viewControllers property just before animating appearance of the overlay :

overlayContainerViewController.viewControllers = [
    mainViewController,
    backdropViewController,
    overlayViewController,
].compactMap { $0 }
overlayContainerViewController.moveOverlay(to: .medium, animated: true)

We end up with the overlayViewcontroller being animated in its height like it should, but also in its width because its view did not layout properly before the begining of the animation.

I could make this work by forcing the layout of the superview of the overlayViewController, but it is a hacky solution, and it would definitely be better if the pod handled this force layout on its own :

overlayContainerViewController.viewControllers = [
    mainViewController,
    backdropViewController,
    overlayViewController,
].compactMap { $0 }
overlayViewController?.view.superview?.setNeedsLayout()
overlayViewController?.view.superview?.layoutIfNeeded()
overlayContainerViewController.moveOverlay(to: .medium, animated: true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions