ios – Dismiss UIFontPickerViewController when font has been chosen or button tapped

[ad_1]

I’m looking for a strategy to dismiss the UIFontPickerViewController when a font has been chosen.

If this isn’t doable, I wish to use the button within the prime proper of the UIFontPickerViewController which isn’t working, I wish to additionally change the title of the Cancel button, to say ‘Finished’, and even to a cross that may dismiss the UIFontPickerViewController, precisely the identical method that the UIColorPickerViewController works.

Class

let fontPicker = UIFontPickerViewController()

In viewDidLoad

fontPicker.delegate = self
current(fontPicker, animated: true, completion: nil)


func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController)
{
    guard let descriptor = viewController.selectedFontDescriptor else
    {
        return
    }

    let font = UIFont(descriptor: descriptor, dimension: textView.font!.pointSize)
    label.font = font
}

That👆 adjustments the font simply as supposed.

This👇 does nothing, it doesn’t matter what I put in there, is not the cancel button within the prime proper meant to do one thing?

func fontPickerViewControllerDidCancel(_ viewController: UIFontPickerViewController)
{
   //This does not appear to do something🤷‍♂️
}

Can I both dismiss the UIFontPickerViewController when a font has been chosen, or change the title to one thing apart from ‘Cancel’, and naturally have it work to dismiss the UIFontPickerViewController?

Thanks prematurely

[ad_2]

Leave a Reply