UIHostingController (text with purple background) is not following it's parent container (blue UIView), even though it has all the constraints to match the parent.
- The blue view is a UIView
- The blue view bottomAnchor is pinned to the keyboardLayoutGuide.topAnchor and has a fixed height.
- The text "Hello I'm here!" with purple background is a SwiftUI view
- I added the SwiftUI view inside the blue view like the following:
let vc = UIHostingController(rootView: CustomText()) addChild(vc) blueView.addSubview(vc.view) vc.didMove(toParent: self) vc.view.translatesAutoresizingMaskIntoConstraints = false vc.view.topAnchor.constraint(equalTo: blueView.topAnchor).isActive = true vc.view.bottomAnchor.constraint(equalTo: blueView.bottomAnchor).isActive = true vc.view.leadingAnchor.constraint(equalTo: blueView.leadingAnchor).isActive = true vc.view.trailingAnchor.constraint(equalTo: blueView.trailingAnchor).isActive = true