2015-11-03 95 views

回答

1

試試這個代碼,這個是寫在OBJ - C的,但你可以從這裏

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: 
                  [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName, 
                  [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]]; 

得到想法上定製更多的選擇,你可以檢查this nice tutorial

2

嘗試像titleTextAttributes屬性的屬性.. 。

let attributesDictionary = [NSFontAttributeName: UIFont(name: "your font name", size: 24)!, NSForegroundColorAttributeName : UIColor.whiteColor()] 
    UINavigationBar.appearance().titleTextAttributes = attributesDictionary 
0
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor], NSFontAttributeName:[UIFont fontWithName:@"mplus-1c-regular" size:21]}]; 
0

如果你想改變字體Ø在斯威夫特

[[UINavigationBar appearance] setTitleTextAttributes: 
    @{NSFontAttributeName:[UIFont systemFontOfSize:22], // font size 
    NSForegroundColorAttributeName:[UIColor yellowColor], // foreground color 
    NSBackgroundColorAttributeName:[UIColor blackColor]}]; // background color 

這樣的::F所有的導航欄,您可以在OC做到這一點

UINavigationBar.appearance().titleTextAttributes = 
    [NSFontAttributeName:UIFont.systemFontOfSize(22), // font size 
    NSBackgroundColorAttributeName:UIColor.yellowColor(), // background color 
    NSForegroundColorAttributeName:UIColor.blackColor()] // foreground color 

但如果你只是想改變一些特定視圖控制器,你可以在OC做到這一點:

[self.navigationController.navigationBar setTitleTextAttributes: 
    @{NSFontAttributeName:[UIFont systemFontOfSize:22], 
     NSForegroundColorAttributeName:[UIColor yellowColor], 
     NSBackgroundColorAttributeName:[UIColor blackColor]}]; 

,這在斯威夫特:

self.navigationController?.navigationBar.titleTextAttributes = 
     [NSFontAttributeName:UIFont.systemFontOfSize(22), 
      NSForegroundColorAttributeName:UIColor.yellowColor(), 
      NSBackgroundColorAttributeName:UIColor.blackColor()] 

希望這些可以有所幫助。