Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 105

Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
10/01/12 09:01 AM (11 years ago)

Custom NavigationBarText (Color and Font)

Hi everyone! I wonder if someone will now how to change navigationBar text? I have fixit on my test app BT2.0 it will work on BT1.5 to. I have only test it on iOS 5. Here can you see I have different fonts and color on my navigationBar. https://dl.dropbox.com/u/83876419/Bt/font1.png https://dl.dropbox.com/u/83876419/Bt/font2.png https://dl.dropbox.com/u/83876419/Bt/font3.png https://dl.dropbox.com/u/83876419/Bt/font4.png All this font works http://iosfonts.com/ What is it worth to know this code? :)) //Mackimack
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/01/12 09:20 AM (11 years ago)
Very cool! This is the kind of information that people tend to freely write tutorials about! But I guess you could also think about writing a plugin that somehow incorporates this information. Mark
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
10/01/12 09:40 AM (11 years ago)
That looks nice! I guess the code would be pretty simple to put together if you look at these two post as references: NavigationBar font color fix -> http://www.buzztouch.com/forum/thread.php?tid=D61B80CE46D3A464BF85D9F Menu list Font Change -> http://www.buzztouch.com/forum/thread.php?tid=0B054A1E2E31CC8E70219CF Once i get back in and settled from traveling i could take a look and post a tutorial if you dont do it first! Thanks for the insight :)
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
10/01/12 09:59 AM (11 years ago)
Nice! I forgot that I had already created a thread on this topic. Here is my new code. //sets the title text from the jsonVars if([[BT_strings getJsonPropertyValue:theScreenData.jsonVars:@"navBarTitleText":@""] length] > 0){ [theViewController.navigationItem setTitle:[BT_strings getJsonPropertyValue:theScreenData.jsonVars:@"navBarTitleText":@""]]; { //font color code UILabel *titleView = (UILabel *)theViewController.navigationItem.titleView; if (!titleView) { titleView = [[UILabel alloc] initWithFrame:CGRectZero]; titleView.backgroundColor = [UIColor clearColor]; titleView.font = [UIFont fontWithName:@"HoeflerText-Italic" size:25.0]; titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]; titleView.textColor = [UIColor cyanColor]; // Change to desired color theViewController.navigationItem.titleView = titleView; [titleView release]; } titleView.text = [BT_strings getJsonPropertyValue:theScreenData.jsonVars:@"navBarTitleText":@""]; [titleView sizeToFit]; } }
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
10/01/12 10:06 AM (11 years ago)
@Mackimack- Thanks for sharing this huge stuff info.
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
10/01/12 01:01 PM (11 years ago)
Nice @Mackimack. Very nice of you to share the full code!
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
03/19/13 08:01 PM (11 years ago)
Where should I place this code? Thanks, Jake
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
07/18/13 03:34 AM (10 years ago)
Thanks @Mackimack! For those reading this, the code doesn't work any more. It needs to be amended slightly, in BT_viewUtilities.m , line 227: //sets the title text from the jsonVars if([[BT_strings getJsonPropertyValue:theScreenData.jsonVars nameOfProperty:@"navBarTitleText" defaultValue:@""] length] > 0){ [theViewController.navigationItem setTitle:[BT_strings getJsonPropertyValue:theScreenData.jsonVars nameOfProperty:@"navBarTitleText" defaultValue:@""]]; { //font color code UILabel *titleView = (UILabel *)theViewController.navigationItem.titleView; if (!titleView) { titleView = [[UILabel alloc] initWithFrame:CGRectZero]; titleView.backgroundColor = [UIColor clearColor]; titleView.font = [UIFont fontWithName:@"HoeflerText-Italic" size:25.0]; titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]; titleView.textColor = [UIColor cyanColor]; // Change to desired color theViewController.navigationItem.titleView = titleView; [titleView release]; } titleView.text = [BT_strings getJsonPropertyValue:theScreenData.jsonVars nameOfProperty:@"navBarTitleText" defaultValue:@""]; [titleView sizeToFit]; } } Hope it helps!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.