How to change the title of "going back" button in NavigationBar?

Hello there,

Does anyone know:

1: How to change the title of the "going back" button in the navigation bar?
2: How to change the colour of the "going back left error" in the navigation bar?

In my attached screenshot, I would like to change the "going back" title "TREAT" to no text and, I would like to change he colour of the "going back left error" from blue to white.

Thanks in advance.

Maria.

Posts

  • Oh, I forgot to say, that I would like to do these changes using C# code in Xamarin.

  • CodeMonkeyCodeMonkey GBMember ✭✭✭

    I use this code to apply a custom back button to my controllers, you should be able to modify it for your needs.

    private void AddCustomBackButton()
            {
                //_________________________
                // Hide default back button
                NavigationItem.SetHidesBackButton(true,true);
    
                //________________________
                // Create a new backbutton
                UIButton button = new UIButton(new RectangleF(0,0,51,27));
                button.SetBackgroundImage(UIImage.FromFile("Images/Shared/backButton.png"), UIControlState.Normal);
                button.VerticalAlignment = UIControlContentVerticalAlignment.Center;
    
                //_______________________
                // Create a new barbutton
                UIBarButtonItem backButton = new UIBarButtonItem();
    
                //____________________________________
                // Make our backbutton the custom view
                // for this barbutton
                backButton.CustomView = button;
    
                //____________________
                // Hook up touch event
                button.TouchUpInside += (sender, e) =>  
                {
                    NavigationController.PopViewControllerAnimated(true);
                } ;
    
                //______________________
                // Add button to nav bar
                NavigationItem.LeftBarButtonItem = backButton;
            }
    
  • Hi Codemonkey. Thanks for your Post. You saved my time.

Sign In or Register to comment.