Billy Coover
Billy Coover

Reputation: 3837

MonoTouch.Dialog: Title Bar color with reflection api

I'm using the MonoTouch.Dialog reflection API to create a new DialogViewController:

var dashBoard = new RootElement (""){
                new Section("My Dashboard", "All alerts, follow-ups, and tasks are automatically synced each time you launch the app") {
                    new StringElement ("Alerts"),
                    new StringElement ("Follow-ups"),
                    new StringElement ("Tasks")
                }
            };

var dvc = new DialogViewController (dashBoard) {
    Autorotate = true
};
navigation.PushViewController (dvc, true);

If I supply the RootElement with a string value I get a nice title bar with text. I want to control the color of that title bar. I'm not seeing any properties that allow me to do this. Do I need to subclass DialogViewController and build my own title bar?

Upvotes: 0

Views: 1025

Answers (1)

Eduardo Scoz
Eduardo Scoz

Reputation: 24753

For me, the easiest way to do this is indeed subclassing the DialogViewController, like this:

public class CustomDialogViewController : DialogViewController {
     // add constructors here as necessary, dont forget to call base()

    public override void ViewWillAppear (bool animated)
    {
        base.ViewWillAppear (animated);
        this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB(0, 115, 176);
    }
}

Upvotes: 3

Related Questions