Thursday, June 14, 2012

Changing Navigation Bar Button colour (color) in MonoTouch and MvvmCross



This was my answer:

At the end of this, I was able to add some bar button changes like:
        var leftButton = new UIBarButtonItem("FooBar", UIBarButtonItemStyle.Bordered, null);
        leftButton.TintColor = UIColor.Green;
        NavigationItem.SetLeftBarButtonItem(leftButton, false);
        NavigationItem.RightBarButtonItem.TintColor = UIColor.Red;
Which resulted in:
four
Alternatively, by placing code in the WelcomeView:
        var leftButton = new UIBarButtonItem("FooBar", UIBarButtonItemStyle.Bordered, null);
        leftButton.TintColor = UIColor.Green;
        NavigationItem.BackBarButton = leftButton;
Then I succeed in achieving:
three
Alternatively, by using code like:
        UIBarButtonItem.AppearanceWhenContainedIn(typeof(UINavigationBar)).TintColor = UIColor.Blue;
Then this enabled me to customise all the navigation bar buttons like:
two

At one point, I also managed to achieve:
one
... but sadly I've genuinely no idea which code combo gave me that! If your problem is with back buttons in particular, then I think you will need to dig around other questions and/or post some code and hope someone can help - there's lots of posts about how to do this, but I can't quite figure out what they all mean for MonoTouch - e.g. Separate title in NavigationBar and navigation buttons

No comments:

Post a Comment