2013-12-19 180 views
-2

我想在全局導航欄上編輯左側和右側項目字體。如何修改導航欄上的左側和右側項目

取消是左邊的項目,並做了正確的項目。

它需要單獨的標題在中間,我已經有了代碼如下(在應用程序委託指定):

NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]]; 
    [titleBarAttributes setValue:[UIFont themeFontNamed:@"viewTitleFont" ofSize:[Constants getTitleFontSize]] forKey:UITextAttributeFont]; 
    [titleBarAttributes setValue:[UIColor themeColorNamed:@"viewTitleColour"] forKey:UITextAttributeTextColor]; 
    [[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes]; 

感謝。

+1

和。 ..你的觀點的結構是什麼?導航控制器?還有哪些其他按鈕將被添加和刪除?你嘗試了什麼? – Wain

+0

http://stackoverflow.com/questions/19029833/ios-7-navigation-bar-text-and-arrow-color – the1pawan

+0

用代碼更新。該stackoverflow問題不是我所需要的,但謝謝。 – jimbob

回答

1

在AppDelegate中的didFinishLaunchingWithOptions在這段代碼工作:

// Change the appearance of back button 
    UIImage *backButtonImage = [[UIImage imageNamed:@"button_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 6)]; 
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; 

    // Change the appearance of other navigation button 
    UIImage *barButtonImage = [[UIImage imageNamed:@"button_normal"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)]; 
    [[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; 

FOT TEXT:

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: 
                  [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor, 
                  [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor, 
                  [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], 
                  UITextAttributeTextShadowOffset, 
                  [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], UITextAttributeFont, nil]]; 

,或者你可以修改文字顏色的按鈕,

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; 
+0

需要修改字體和字體顏色我的不好。 – jimbob

+0

回答爲文本編輯 – Firegab

相關問題