I found a solution for those looking to replace ALL section headers in the entire solution. In MonoTouch.Dialog
, there is a class named DialogViewController
which is used when creating views with the reflection API. And in here, there's a method called GetViewForHeader()
. Instead of sending back just the normal section.HeaderView
, you can create a custom label and send that back.
public override UIView GetViewForHeader (UITableView tableView, int sectionIdx)
{
var section = Root.Sections [sectionIdx];
if (!string.IsNullOrEmpty(section.Caption))
{
var label = new UILabel();
label.BackgroundColor = UIColor.FromRGB(89, 41, 17);
label.TextColor = UIColor.FromRGB(255, 206, 52);
label.ShadowColor = UIColor.Black;
label.ShadowOffset = new SizeF(0, 1f);
label.Font = UIFont.FromName("TitlingGothicFB Cond", 20);
label.Text = section.Caption;
return label;
}
return section.HeaderView;
}
public override float GetHeightForHeader (UITableView tableView, int sectionIdx)
{
if (!string.IsNullOrEmpty(section.Caption))
return 40f;
return -1;
}
Remember to set the height, either manually or by getting the height from the label. You can also create a custom UIView
, but a label was sufficient for me.