MonoTouch.Dialog:带反射API的标题栏颜色

时间:2011-03-14 07:13:18

标签: xamarin.ios uitableview monotouch.dialog

我正在使用MonoTouch.Dialog反射API来创建一个新的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);

如果我为RootElement提供字符串值,我会得到一个带文本的好标题栏。我想控制标题栏的颜色。我没有看到任何允许我这样做的属性。我是否需要继承DialogViewController并构建自己的标题栏?

1 个答案:

答案 0 :(得分:3)

对我来说,最简单的方法就是将DialogViewController子类化,如下所示:

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);
    }
}