【问题标题】:UITableView text overtop of my custom section header?UITableView 文本覆盖我的自定义部分标题?
【发布时间】:2014-03-28 17:51:18
【问题描述】:

我的问题是,当我在 UITableView 中滚动时,行文本会出现在部分标题文本的正上方。当下一个部分标题出现时,它会强制上一个部分滚动(正如预期的那样)。

这是我的代码 公共覆盖 UIView GetViewForHeader (UITableView tableView, int section) { var myHeader = new UIView (); myHeader.Frame = new RectangleF (10, 0, 320, 30);

        var lbl = new UILabel ();
        lbl.Frame = new RectangleF(10, 8, 320, 20);
        lbl.Text = TitleForHeader (tableView, section);
        lbl.Font = UIFont.BoldSystemFontOfSize (18f);
        lbl.Center = myHeader.Center;

        myHeader.AddSubview(lbl);
        return myHeader;
    }

    public override float GetHeightForHeader (UITableView tableView, int section)
    {
        return GetViewForHeader (tableView, section).Frame.Height;
    }

我错过了什么?

【问题讨论】:

    标签: ios xamarin


    【解决方案1】:

    总台时刻。

    视图的默认行为是具有透明背景。一旦我设置了 myHeader.BackgroundColor = tableview.BackgroundColor,它就会按预期工作。

    【讨论】:

      猜你喜欢
      • 2013-03-14
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多