How do I get the font name from an otf or ttf file?

前端 未结 15 1588
-上瘾入骨i
-上瘾入骨i 2020-11-28 03:44

I have used a custom font in my previous app.

The file name was \"ProximaNova-Regular.otf\" and to load the font I just used...

[UIFont fontWithName:         


        
15条回答
  •  有刺的猬
    2020-11-28 04:07

    Swift 4.0 Supported

    This is only one line code for print all font family and it's font's names

    override func viewDidLoad() {
        super.viewDidLoad()
        //Main line of code
        UIFont.familyNames.sorted().forEach({ print($0); UIFont.fontNames(forFamilyName: $0 as String).forEach({print($0)})})
    }
    

提交回复
热议问题