Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone UINavigationBar change font style for all controllers with [UINavigationBar appearance]

I'm aware that I can individually change the font of a navigation bar as outlined in this answer: Change the navigation bar's font

Currently I'm using a more global approach:

//in my app delegate:
    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];

Is there a way to globally change the font that the Navbar through the appearance object?

thank you!

like image 531
Alex Stone Avatar asked Dec 08 '11 04:12

Alex Stone


People also ask

How do I change the color of my UINavigationBar?

Open the project's storyboard file. Select the UINavigationBar from your UINavigationController scene. In the Attributes Inspector pane turn on these Appearances: “Standard”, “Compact”, “Scroll Edge”, and “Compact Scroll Edge”. For all four appearances, set the “Background” to “System Red Color”, for example.

Can you change the navigation bar on Iphone?

Change the Bar StyleA user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

How do I customize my navigation bar?

From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.


1 Answers

From Ray Wenderlich:

http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5

// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.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:@"Arial-Bold" size:0.0], 
    UITextAttributeFont, 
    nil]];
like image 169
TigerCoding Avatar answered Oct 02 '22 02:10

TigerCoding