我的应用程序中有两个 UITable 静态部分,具有不同的 header 。 由于自定义背景,必须更改标题的颜色。
如何在我的 MonoTouch 应用程序中执行类似 ( link ) 的解决方案?
因为我使用静态部分,所以我没有可以在其中执行操作的 UITableViewSource。
我的解决方案(感谢 Krumelur)
[Export("tableView:viewForHeaderInSection:")]
UIView GetViewForHeaderInSecion (UITableView tableview, int section)
{
UIView view = new UIView (new RectangleF (0, 0, 300, 0));
view.BackgroundColor = UIColor.Clear;
UILabel label = new UILabel (new RectangleF (15, 5, 300, 25));
label.BackgroundColor = UIColor.Clear;
label.TextColor = UIColor.White;
label.ShadowColor = UIColor.Black;
label.ShadowOffset = new SizeF(0, 1);
label.Font = UIFont.BoldSystemFontOfSize(18);
if (section == 0) {
label.Text = "First section";
} else {
label.Text = "Second section";
}
view.AddSubview(label);
return view;
}
最佳答案
您必须导出 Controller 中缺少的方法。类似于:
[Export("tableView:viewForHeaderInSection:")]
UIView GetViewForHeaderInSection(UITableView tableview, int section
{
// return your UIView with whatever background color here
}
请注意,您无法更改预定义 View 的颜色,而必须返回整个 View 。
关于xamarin.ios - 更改颜色标题 UITable 静态部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13876880/