Click here to Skip to main content
15,885,213 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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)
Posted
Updated 5-Jul-17 2:40am
v2

1 solution

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.
 
Share this answer
 
Comments
Mohammad Hasanpoor 5-Jul-17 16:06pm    
but i created the font.
i told.
i am new in swift. i try but i can not understand the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900