如何在swift 3中更改标签栏字体 [英] How can I change tab bar font in swift 3
本文介绍了如何在swift 3中更改标签栏字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的朋友。我是swift和ios的新手。
i希望在swift 3和xcode 8中更改我的标签栏字体。
但我有问题。
i在appDelegate.swift中的方法func application(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - > Bool中编写此代码:
hi my friend. i am new in swift and ios.
i want change my tab bar font in swift 3 and xcode 8.
but i have problem.
i write this code in "AppDelegate.swift" in method "func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool :"
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "IRANSansWeb.ttf", size: 10)!], for: .normal)
但我有这个错误:
but i have this error:
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
什么是解决方案???
我尝试过的方法:
what is the solution???
What I have tried:
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "IRANSansWeb.ttf", size: 10)!], for: .normal)
推荐答案
在UITabBarItem调用之前创建字体。我猜它是零,因为Font是nil,因为它被拼错了。
尝试详细了解错误消息。
Create the Font before the UITabBarItem call. I guess it is nil, because the Font is nil because it is mispelled.
Try to understand the error messages in detail.
这篇关于如何在swift 3中更改标签栏字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文