Discussion Forums  >  Status Bar, Navigation Bar

Replies: 20    Views: 351

Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
02/09/13 04:59 PM (11 years ago)

Change top left nav button text colour

Hi I would like to change the text colour of my top left back button in the navigation bar. I followed a tutorial to change the button colour but my project decided to change the text colour from white to black, I would like to change it back to white. The code I inserted wont over write this text colour in the top left nav button. Is the back button text colour controlled else where in the project? How can I change?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/09/13 05:19 PM (11 years ago)
I'm not sure if I have the answer, but I can comment... I had the same issues with my nav bar; I can create one, but it gets overridden... I 'suspect' (because I haven't delved into it yet) that the code you (and later, I) are looking for is in one of the BT_NavController files... Cheers! -- Smug
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 03:28 AM (11 years ago)
Here is the code have just tested it. Place it after the line //setup navigation bar and background [BT_viewUtilities configureBackgroundAndNavBar:self:[self screenData]]; in the view did appear method NSDictionary *leftAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor blueColor], // text color change to whatever UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil]; [self.navigationItem.leftBarButtonItem setTitleTextAttributes:leftAttributes forState:UIControlStateNormal]; [self.navigationItem.leftBarButtonItem setTintColor:[UIColor redColor]]; //Button color cnahge to whatever color }
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 03:28 AM (11 years ago)
Will check this out. Thanks for the reply.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 03:32 AM (11 years ago)
Hi Kittsy You are actually the person I want to speak to. I have used the code above from a previous post you had committed on and it does work accept for the left button (back button). It might be the 'menu with image' plugin that's the issue, it won't change the left button text colour. Any ideas?
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 03:39 AM (11 years ago)
I just notice something about the code you posted, it doesn't include the right button and the code I have from your previous post I think might be for the right only. Can you post code that is for both buttons or do I just add this code to the code I already have, which worked on the right button. This was the previous post: https://www.buzztouch.com/forum/thread.php?tid=6644B175D75800E20FFBE2C&fid=A2F08DF30D5B47C3F930107&sortColumn=FT.id&sortUpDown=DESC&currentPage=1
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 03:41 AM (11 years ago)
The bottom two lines control the above code If you want to change all the navbar items to the smae theme use [[UIBarButtonItem appearance] setTitleTextAttributes: attributes forState: UIControlStateNormal]; [[UIBarButtonItem appearance] setTintColor:[UIColor redColor]]; // Button color For the right button only use [self.navigationItem.rightBarButtonItem setTitleTextAttributes:rightAttributes forState:UIControlStateNormal]; [self.navigationItem.rightBarButtonItem setTintColor:[UIColor blueColor]]; //Button color For the left button use [self.navigationItem.leftBarButtonItem setTitleTextAttributes:leftAttributes forState:UIControlStateNormal]; [self.navigationItem.leftBarButtonItem setTintColor:[UIColor redColor]]; //Button color cnahge to whatever color notice the code leftBarButtonItem / rightBarButtonItem / UIBarButtonAppearance they are what you are changing the setTitleTextAttributes are the NSDictionary stuff you set up I named them leftAttributes, rightAttributes and attributes for all of them So although the code may have looked the same there are slight differences
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 03:43 AM (11 years ago)
To do both is NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor], // text color UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil]; [[UIBarButtonItem appearance] setTitleTextAttributes: attributes forState: UIControlStateNormal]; [[UIBarButtonItem appearance] setTintColor:[UIColor redColor]]; // Button color
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 03:52 AM (11 years ago)
Ok, let me get my head arond this, should I just replace the final code above with the old one I used?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 03:54 AM (11 years ago)
Describe what it is it that you want to happen
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 03:59 AM (11 years ago)
Change the colour of both the left and right nav bar buttons and text colour.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 04:04 AM (11 years ago)
Use this NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor], // text color UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil]; [[UIBarButtonItem appearance] setTitleTextAttributes: attributes forState: UIControlStateNormal]; [[UIBarButtonItem appearance] setTintColor:[UIColor redColor]]; // Button color if you want the colors to match
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 04:07 AM (11 years ago)
great, will try now.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 04:12 AM (11 years ago)
Hi Kittsy ok, it works but there appears to be a glitch on the 'Menu Image' plugin. When you enter the page the text is black, but if I navigate away and then go back to the page its white. Confused to why its doing this, don't know if you have an app to test on this plugin?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 04:41 AM (11 years ago)
I haven't got that plugin to test sorry, it works on the plugins I have tested
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 04:44 AM (11 years ago)
ok, no worries, thanks for helping.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 04:45 AM (11 years ago)
I can't see why
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
02/10/13 05:39 AM (11 years ago)
I find the 'Menu with Image' plugin a bit buggy anyway. You have helped me enough and I appreciate it. You seem to have all the answers!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 05:58 AM (11 years ago)
I like ios someone asks a question I like to try and find i tout
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/10/13 02:36 PM (11 years ago)
Kittsy: So, if I were an adventurous sort, I could research the options to the lines that go like... (left, right, whatever) ...Attributes forState:UIControlStateNormal And if I could find out what other states there are than 'normal', I could change the color on those states as well, right? Cheers! -- Smug
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
02/10/13 02:39 PM (11 years ago)
Yup but you can't change the button tint color for some reason. You could change the text color for uicontrolstatehighlighted.
 

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.