1

我正在尝试使用 monotouch.dialog 创建自定义条目元素。我了解如何对 StringElement 进行子类化以设置我自己的字符串元素的样式 - 请参见下面的示例:

public class CustomStyledStringElementPlain : MonoTouch.Dialog.StyledStringElement
{
    public CustomStyledStringElementPlain (string _caption, UIColor _backgroundcolour, UITextAlignment _alignment) : base(string.Empty,string.Empty)
    {
        TextColor = UIColor.White;
        Font = UIFont.FromName ("Helvetica-Bold", 14f);
        Caption = _caption;
        Alignment = _alignment;
        BackgroundColor = _backgroundcolour;
    }
}

但是,当对 EntryElement 进行子类化时,例如,我无法访问 BackgroundColor 的属性(这是我要更改的主要内容!)这是我到目前为止所拥有的...关于如何更改的任何指针或建议背景颜色或其他样式条目元素将不胜感激!

public class CustomStyledEntryElementPlain : MonoTouch.Dialog.EntryElement
{
    public CustomStyledEntryElementPlain (string _caption, UIColor _colour, UITextAlignment _alignment) : base(string.Empty,string.Empty)
    {
        ReturnKeyType = UIReturnKeyType.Done;
        Caption = _caption;
    }
}
4

1 回答 1

1

要自定义 MonoTouch.Dialog 元素,您可以覆盖 GetCell 方法并在单元格对象上设置所需的外观。像这样的东西:

public override UITableViewCell GetCell(UITableView tableView) {
    var cell = base.GetCell(tableView);
    cell.BackgroundColor = _colour;
    return cell;
}
于 2013-03-28T08:10:52.677 回答