How to animate `UIHostingController.view` frame when my View's size changes?

I have a UIHostingController on which I have set:

hostingController.sizingOptions = [.intrinsicContentSize]

The size of my SwiftUI content changes with animation (I update a @Published property on an ObservableObject inside a withAnimation block). However, I notice that my hostingController.view just jumps to the new frame without animating the change.

Question: how can I animate the frame changes in UIHostingController that are caused by sizingOptions = [.intrinsicContentSize]

Hello @isaacweisberg,

UIKit has its own .animate you can use on observed changes of .preferredContentSize, which reflects the view's current size.

For more information, ⌘+Click on a .UIHostingController in Xcode to read through the DocC comments that provides much context.

 Travis Trotto - DTS Engineer

How to animate `UIHostingController.view` frame when my View's size changes?
 
 
Q