/// <summary> /// Definition for the Header of the MVVM ObservableTable object /// </summary> /// <returns>The view for header.</returns> /// <param name="tableView">Table view.</param> /// <param name="section">Section.</param> public static UIView GetViewForHeader(UIKit.UITableView tableView, nint section) { var headerView = new UITableViewHeaderFooterView(); headerView.BackgroundColor = UIColor.FromRGB(173, 203, 209); UILabel fn = new UILabel(new CoreGraphics.CGRect(0, 5, 100f, 22f)); fn.Font = UIFont.SystemFontOfSize(14f); fn.TextAlignment = UITextAlignment.Left; fn.TextColor = UIColor.Black; fn.Text = "First Name"; UILabel ln = new UILabel(new CoreGraphics.CGRect(101, 5, 300f, 22f)); ln.Font = UIFont.SystemFontOfSize(14f); ln.TextAlignment = UITextAlignment.Left; ln.TextColor = UIColor.Black; ln.Text = "Last Name"; headerView.Add(fn); headerView.Add(ln); return(headerView); }
void ShowSelector(string selectorTitle, string selectorSubtitle, UITableViewSource tableViewSource, string footerButtonTitle = "", Action doneAction = null, Action footerButtonAction = null) { try { UILabel selectorTitleLabel = new UILabel(); UILabel selectorSubtitleLabel = new UILabel(); UIButton doneButton = new UIButton(UIButtonType.System); UIButton footerButton = new UIButton(UIButtonType.System); UITableViewHeaderFooterView tableHeader = new UITableViewHeaderFooterView(); UITableViewHeaderFooterView tableFooter = new UITableViewHeaderFooterView(); if (selectorTableView != null) { selectorTableView.RemoveFromSuperview(); selectorTableView.Dispose(); } tableHeader.Frame = new CGRect(20, 0, View.Window.Frame.Width - 20, 50); tableFooter.Frame = new CGRect(0, 0, View.Window.Frame.Width - 20, 50); selectorTitleLabel.Text = selectorTitle; selectorTitleLabel.TextColor = UIColor.Black; selectorTitleLabel.AdjustsFontSizeToFitWidth = true; selectorTitleLabel.Frame = new CGRect(15, -5, tableHeader.Frame.Width / 2, 50); selectorSubtitleLabel.TextColor = UIColor.LightGray; selectorSubtitleLabel.Text = selectorSubtitle; selectorSubtitleLabel.Frame = new CGRect(15, 10, tableHeader.Frame.Width / 2, 50); selectorSubtitleLabel.Font = UIFont.SystemFontOfSize(10); doneButton.SetTitle("Done", UIControlState.Normal); doneButton.Font.WithSize(12); footerButton.SetTitle(footerButtonTitle, UIControlState.Normal); footerButton.Font.WithSize(12); doneButton.TouchUpInside += (sender, e) => { selectorTableView.Hidden = true; doneAction?.Invoke(); ControlMenu("Show"); gameLayer.GamePaused = false; }; doneButton.Frame = new CGRect(tableHeader.Frame.Width - doneButton.Frame.Width - 58, 10, 50, 30); footerButton.TouchUpInside += (sender, e) => { selectorTableView.Hidden = true; footerButtonAction?.Invoke(); ControlMenu("Show"); gameLayer.GamePaused = false; }; footerButton.Frame = new CGRect(3, 20, 100, 20); tableHeader.Add(selectorTitleLabel); tableHeader.Add(selectorSubtitleLabel); tableHeader.Add(doneButton); tableFooter.Add(footerButton); selectorTableView = new UITableView(); selectorTableView.Layer.BorderColor = new CGColor(0.7f, 0.7f, 0.7f, 0.8f); selectorTableView.Layer.BorderWidth = 1; selectorTableView.Layer.CornerRadius = 8; selectorTableView.BackgroundColor = new UIColor(1, 1, 1, 0.8f); selectorTableView.TableHeaderView = tableHeader; selectorTableView.TableFooterView = tableFooter; selectorTableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; selectorTableView.Frame = new CGRect(0, 0, View.Window.Frame.Width - 20, (selectorTableView.ContentSize.Height + 50 < 270 ? selectorTableView.ContentSize.Height + 50 : 270)); selectorTableView.Center = new CGPoint(View.Window.Frame.Width / 2, View.Window.Frame.Height / 2); selectorTableView.Source = tableViewSource; if (philipsHue.ColorBulbs.Count > 5) { selectorTableView.ScrollEnabled = true; selectorTableView.ScrollsToTop = true; selectorTableView.ShowsVerticalScrollIndicator = true; selectorTableView.ShowsHorizontalScrollIndicator = false; selectorTableView.FlashScrollIndicators(); } Add(selectorTableView); } catch (Exception ex) { throw ex; } }