Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 483

Pogden
Aspiring developer
Profile
Posts: 19
Reg: Sep 03, 2011
Surrey
1,490
05/28/22 11:05 AM (2 years ago)

How do you change the Nav Bar Text Color in the latest version on Buzztouch

After many years I have been asked to update an old app I made. To my surprise I have been able to get the app up and running pretty good. The last thing I need to do before I submit the app to the App Store is change the nav bar and status bar text to white for iOS devices. Unfortunately that is where I am stuck. It seem like the way I have done this in the past no longer works. After scouring the forum for answers, I have stumbled across tweaking the lines 241 - 245 in the BT_viewController, and adding a manual JSON value in the global theme that seems to be referenced in the code. But, nothing has worked for me up to this point. If anyone has the knowledge I am searching for please share. Thank you.
 
Cakebit
Code is Art
Profile
Posts: 501
Reg: Dec 15, 2010
In your local b...
16,510
like
05/28/22 04:32 PM (2 years ago)
Hi Pogden! You can add the following code snippet to your BT_viewController.m somewhere around line 231 (replacing the [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault]; line). [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent]; [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]; This will change both the status bar text and nav-bar title to white. :) Let me know if you have any questions! Thanks!! Edit: Just for more detail, this seems to be a bug introduced by iOS 15 extending the `scrollEdgeAppearance` which by default produces a transparent background, to all navigation bars. https://developer.apple.com/forums/thread/682420 I'll need to push out a bug fix to get `navBarTitleTextColor` to work in iOS 15+.
 
Pogden
Aspiring developer
Profile
Posts: 19
Reg: Sep 03, 2011
Surrey
1,490
like
05/28/22 06:10 PM (2 years ago)
Thank you for getting back to me so quickly. Changing the code as you described did the trick. The only thing is that the fix is only temporary. Fo some reason the title text changes back to black after going back and forth through a few screens. Any idea why this would be?
 
Cakebit
Code is Art
Profile
Posts: 501
Reg: Dec 15, 2010
In your local b...
16,510
like
05/28/22 06:39 PM (2 years ago)
I can't seem to reproduce the issue locally... but it may help to add [navBarAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]; to line 274, right below the [navBarAppearance setBackgroundColor:[BT_color getColorFromHexString:tmpBarBackgroundColor]]; line... perhaps the title color is being overridden in this section..? Let me know if that works, or if you want me to take a look at your project. Thanks!
 
Pogden
Aspiring developer
Profile
Posts: 19
Reg: Sep 03, 2011
Surrey
1,490
like
05/29/22 11:10 AM (2 years ago)
Thanks again. That worked to stop the nav bar title text from reverting. The status bar still changes back to a black font color. Is there a similar code snippet that would stop that as well?
 
Pogden
Aspiring developer
Profile
Posts: 19
Reg: Sep 03, 2011
Surrey
1,490
like
05/29/22 12:16 PM (2 years ago)
Thanks again. That worked to stop the nav bar title text from reverting. The status bar still changes back to a black font color. Is there a similar code snippet that would stop that as well?
 
Cakebit
Code is Art
Profile
Posts: 501
Reg: Dec 15, 2010
In your local b...
16,510
like
05/31/22 08:01 PM (2 years ago)
Ok, I can reproduce the issue now... while I dig into it, you can force the status bar to be a specific color (light/dark) for your entire app. To do this, go to your BT_info.plist file (it's in the BT_Config folder) and set the following values: UIViewControllerBasedStatusBarAppearance: 0 UIStatusBarHidden: 0 UIStatusBarStyle: UIStatusBarStyleLightContent (You can set these values in Xcode or copy and paste these keys into your BT_info.plist using any text editor) <key>UIStatusBarHidden</key> <false/> <key>UIStatusBarStyle</key> <string>UIStatusBarStyleLightContent</string> <key>UIViewControllerBasedStatusBarAppearance</key> <false/> Then comment out line 69 in the yourAppName_appDelegate.m to prevent the status bar from being hidden. I'll update this thread when I have a fix that doesn't require this "global work-around".
 
Pogden
Aspiring developer
Profile
Posts: 19
Reg: Sep 03, 2011
Surrey
1,490
like
06/01/22 03:52 PM (2 years ago)
Worked like a charm! Once again thank you for providing a solution to all of these issue I had with my app.
 

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.