Setting color of back button in IOS 7

Hi everyone,
I am currently playing around with new appearance settings in iOS 7 and can't find the way how can change Back button color. Can some one share code for this.

I was trying following:
UIBarButtonItem buttonback = new UIBarButtonItem ("Retry", UIBarButtonItemStyle.Plain, null);
buttonback.TintColor = UIColor.Brown;
NavigationItem.BackBarButtonItem = buttonback;

Posts

  • UINavigationBar.Appearance.TintColor = UIColor.Red;

  • Bob_ReckBob_Reck USMember ✭✭✭

    @mikollv123,

    I do this when I change something on my form. I change my "Save" button to be red. I use:

    NavigationItem.RightBarButtonItem.TintColor = UIColor.Red;

    You can also use LeftBarButtonItem.

    Bob

  • mikollv123mikollv123 USMember

    Have tried this code, but the button is still blue color. I am putting this code in ViewDidLoad

  • mikollv123mikollv123 USMember

    @Bob
    I have tried your code but I get NullException

  • Bob_ReckBob_Reck USMember ✭✭✭

    @mikollv123, are you using a navigation controller? Maybe not now that I look at your code again.

  • Bob_ReckBob_Reck USMember ✭✭✭

    @mikollv123,
    Looking at the apple sdk documentation, your code should work for a buttonbaritem. I'm not near my computer at the moment though (responding via my phone) but will give it a try when I am.

    Bob

  • Bob_ReckBob_Reck USMember ✭✭✭

    @mikollv123,

    Ok, I just tried changing the color of one of my buttons to green and it worked fine. Here's my code:

    UIToolbar myToolbar = new UIToolbar(RectangleF.Empty);
    myToolbar.BarStyle = UIBarStyle.Black;
    myToolbar.Translucent = true;
    myToolbar.UserInteractionEnabled = true;
    myToolbar.SizeToFit();
    btnCancel = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, KBToolbarButtonDoneHandler);
    btnCancel.TintColor = UIColor.Green;
    btnFlexibleSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
    btnDone = new UIBarButtonItem(UIBarButtonSystemItem.Done, mfgPickerButtonDoneHandler);
    btnItems = new UIBarButtonItem[] { btnCancel, btnFlexibleSpace, btnDone }; 
    myToolbar.SetItems(btnItems, true);
    

  • mikollv123mikollv123 USMember

    @Bob,

    Thank you i will try your code. Yes i am using navigation controller

  • Bob_ReckBob_Reck USMember ✭✭✭
    edited October 2013

    @mikollv123,

    Ok, then my code above won't work for your situation. That example is adding a toolbar to a view and changing the button color on it. If your trying to change a button on a navigation controller, then the line in my first response should work. If you're getting a null exception, then there's something else wrong.

    What is null? The navigationItem? Or the RightBarButtonItem (or left)?

    Try this:

    NavigationItem.BackBarButtonItem.TintColor = UIColor.Red;

    Bob

  • mikollv123mikollv123 USMember

    @Bob,

    Thank you for assistance. It started to work.

  • Bob_ReckBob_Reck USMember ✭✭✭

    Good to hear!
    Bob

Sign In or Register to comment.