iOS - Globally change navigation bar title color using appearance?

前端 未结 6 1718
情歌与酒
情歌与酒 2021-02-07 00:56

This crashes the app:

[[UINavigationBar appearance] setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];

Is there a way to do

6条回答
  •  青春惊慌失措
    2021-02-07 01:54

    Here's an example of how to do this in Swift:

    UINavigationBar.appearance().titleTextAttributes =
      [NSFontAttributeName:UIFont(name:"Exo2-Bold", size: 18) as! AnyObject,
      NSForegroundColorAttributeName:UIColor.whiteColor()]
    

提交回复
热议问题