简体   繁体   中英

UITableView text overtop of my custom section header?

My issue is that when I scroll in my UITableView, the row text ends up right over top of my section header text. When the next section header comes along, it forces the previous one to scroll off (which is as expected).

Here's my code public override 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;
    }

What am I missing?

Head-desk moment.

The default behaviour for a view is to have a transparent background. Once I set the myHeader.BackgroundColor = tableview.BackgroundColor it worked as I expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM