Custom Fonts only available when set in Interface Builder

前端 未结 6 1086
暖寄归人
暖寄归人 2021-01-13 08:50

I have added a custom font to my project. It is included in the target, and it is added in the plist. When I try to use it programmatically it doesn\'t work, and it doesn\'t

6条回答
  •  星月不相逢
    2021-01-13 09:33

    Issue is You are not giving ProperName Of Fonts in Code, for Getting Name of Fonts please run this code.

     for family: String in UIFont.familyNames
        {
            print("\(family)")
            for names: String in UIFont.fontNames(forFamilyName: family)
            {
                print("== \(names)")
            }
        }
    

    it will prints all fonts, search your font and give proper name.

     let attributedText = NSMutableAttributedString(string: "We 
     Apologize! \n This feature is only available for \n Go 4.0 
     Subscriptions", attributes: [NSAttributedStringKey.font : 
     UIFont(name: "SpecialElite-Regular", size: 22)!])
    

提交回复
热议问题