Using custom font for entire iOS app swift

前端 未结 5 1359
南方客
南方客 2020-11-29 04:48

I know that to set a custom font of an element on the screen I can simply dosomeLabel.font=UIFont(name: \"Exo 2.0\", size: 15).

I was wondering how one

5条回答
  •  迷失自我
    2020-11-29 05:14

    FINALLY figured this out. Cleanest way I could find. (Swift 4) Solution doesn't require you to set font sizes and won't override all font sizes.

      UILabel.appearance().font = UIFont.preferredFont(forTextStyle: UIFontTextStyle(rawValue: "Roboto"))
    

    For those looking for where to place this code. I put it in my AppDelegate.swift file inside of

     func application(_ application: UIApplication, 
     didFinishLaunchingWithOptions...
    

    Swift 4.2

     UILabel.appearance().font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle(rawValue: "Roboto"))
    

提交回复
热议问题