I have made a font picker but the problem is that I can’t seem to figure out why there is no navigation bar with a cancel button and search bar. Normally there would be but with this there isn’t (there is a fontPickerViewControllerDidCancel method but no cancel button).
Has anyone else had this problem, and is there a way to resolve this?
Has anyone else had this problem, and is there a way to resolve this?
Code Block Swift struct FontPicker: UIViewControllerRepresentable { class Coordinator: NSObject, UIFontPickerViewControllerDelegate { private let parent: FontPicker init(_ parent: FontPicker) { self.parent = parent } func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { parent.presentationMode.wrappedValue.dismiss() guard let descriptor = viewController.selectedFontDescriptor else { return } let font = UIFont(descriptor: descriptor, size: 17) parent.fontName = font.fontName } } @Environment(\.presentationMode) private var presentationMode @Binding var fontName: String func makeUIViewController(context: Context) -> some UIViewController { let configuration = UIFontPickerViewController.Configuration() configuration.includeFaces = true let picker = UIFontPickerViewController(configuration: configuration) picker.delegate = context.coordinator return picker } func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} func makeCoordinator() -> Coordinator { Coordinator(self) } } // used in a View like this Button("Choose font") { showingFontPicker = true } .sheet(isPresented: $showingFontPicker) { FontPicker(fontName: $newFontName) .ignoresSafeArea() }