Is there a way to get the size inside a UIViewControllerRepresentable? I try to include a UIKit control that requires me to put the size in it's constructor.
This is my code so far:
And this is, how I currently use this:
Question now is, how do I get the size that SwiftUI will apply to my frame?
This is my code so far:
Code Block final class ChartVC: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { let viewController = UIViewController() let chart = Chart(frame: CGRect(x: 0, y: 0, width: 300, height: 200)) //todo: don't use fixed values here... viewController.view.addSubview(chart) return viewController } func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } }
And this is, how I currently use this:
Code Block ChartVC() .frame(minWidth: 180, idealWidth: 280, maxWidth: 420, minHeight: 300, alignment: .center) .padding() .background(Color.contentBackgroundColor) .cornerRadius(8)
Question now is, how do I get the size that SwiftUI will apply to my frame?