3

我想使用 MonoTouch.Dialog RadioElements 来选择数据,并且它必须有一个 UIImageView 用于 TableView BackgroundViews。

我可以在初始 DialogViewController 的 TableView 上设置 BackgroundView,所以那里没有问题,但是为每个 RadioGroup 生成的 TableView 具有默认的灰色背景图像,我似乎无法找到将它们更改为与初始 TableView 相同的背景样式的方法.

是否可以更改生成的 TableView 的 BackgroundView(为每个 RadioGroup 生成的 TableView)而无需修改 MonoTouch.Dialog 源?

提前致谢。

4

2 回答 2

3

AFAIK 你需要创建自己的元素。但消息是这很容易做到,例如:

public class TransparentRootElement : RootElement {

    // add required .ctors

    public override UITableViewCell GetCell (UITableView tv)
    {
        var cell = base.GetCell (tv);
        cell.BackgroundColor = UIColor.Clear;
        return cell;
    }
}

然后,您只需TransparentRootElement在创建RadioGroup.

于 2011-10-26T01:38:07.087 回答
0
public class CustomRootElement : RootElement
{
    public CustomRootElement(string caption, RadioGroup group) : base(caption, group)
    {

    }
    protected override MonoTouch.UIKit.UIViewController MakeViewController()
    {
        DialogViewController result = (DialogViewController)base.MakeViewController();
        // set the background here
        result.TableView.BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;

        return result;
    }

}
于 2012-07-22T23:05:58.000 回答