public struct ReadableWidthView: UIViewControllerRepresentable { public typealias UIViewControllerType = UIViewController private let content: Content init(@ViewBuilder content: () -> Content) { self.content = content() } public func makeUIViewController(context: Context) -> UIViewController { let viewController = UIViewController() let view = viewController.view! let hostingController = UIHostingController(rootView: content) viewController.addChild(hostingController) view.addSubview(hostingController.view) hostingController.view?.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ hostingController.view.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor), hostingController.view.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor), hostingController.view.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor), hostingController.view.bottomAnchor.constraint(equalTo: view.readableContentGuide.bottomAnchor), ]) hostingController.didMove(toParent: viewController) return viewController } public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { guard let hostingController = uiViewController.children.lazy.compactMap({ $0 as? UIHostingController }).first else { return } hostingController.rootView = content } }