0

我正在使用 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 并构建自己的标题栏吗?

4

1 回答 1

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);
    }
}
于 2011-03-14T13:14:34.040 回答