UIFontPickerViewController
A view controller that manages the interface for selecting a font that the system provides or the user installs.
Declaration
@MainActor class UIFontPickerViewControllerOverview
Use a UIFontPickerViewController to provide the user access to all the fonts on their device. Directly querying UIFont provides only system fonts, but the user may have additional fonts on their device. When the user selects one of these nonsystem fonts in the font picker, the system grants your app access to the font.
The font picker has several customization options collected into a UIFontPickerViewController.Configuration object. For example, you can set includeFaces to true so that the user can select not only the font but a bold or italic face within that font family. Customize the configuration object first, then pass it as an argument in the font picker’s init(configuration:) method.
func showFontPicker(_ sender: Any) {
let fontConfig = UIFontPickerViewController.Configuration()
fontConfig.includeFaces = true
let fontPicker = UIFontPickerViewController(configuration: fontConfig)
fontPicker.delegate = self
self.present(fontPicker, animated: true, completion: nil)
}When your UIFontPickerViewControllerDelegate receives fontPickerViewControllerDidPickFont(_:), retrieve information about the user’s selected font from the font picker’s selectedFontDescriptor.