ios - Change font in navigation bar in Swift -


I want to change the font in the navigation bar, though the following code is not working, this causes the application to crash .

  func application (application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) - & gt; Bull {UINavigationBar.appearance (). TitleTextAttributes = [NSFontAttributeName: UIFont (name: "Lato-Light.ttf", Size: 34)!] Return true}  

I get the following error:

Fatal error: Unexpectedly found zero during opening an optional value (LLDB)

I have actually added the font Lato-Light Has been sent to its project, so it should be able to find it.

UIFont () is a fusible intiLiizer, it fails for several reasons Could. ! A forced opening crashes your app using .

Start it better separately and check success:

  if font = UIFont (name: "Lato-Light.ttf", size: 34) {UINavigationBar.appearance (). TitleTextAttributes = [NSFontAttributeName: font]}  

and check whether your font file is included in bundled resources.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -