public DropdownMenuTableViewCell(UITableViewCellStyle style, string reuseIdentifier, DropdownMenuConfiguration configuration) : base(style, reuseIdentifier) { this.Configuration = configuration; // Setup cell CellContentFrame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, this.Configuration.CellHeight); this.ContentView.BackgroundColor = this.Configuration.CellBackgroundColor; this.SelectionStyle = UITableViewCellSelectionStyle.None; this.TextLabel.TextAlignment = UITextAlignment.Left; this.TextLabel.TextColor = this.Configuration.CellTextLabelColor; this.TextLabel.Font = this.Configuration.CellTextLabelFont; this.TextLabel.Frame = new CGRect(20, 0, CellContentFrame.Width, CellContentFrame.Height); // Checkmark icon this.CheckMarkIcon = new UIImageView(new CGRect(CellContentFrame.Width - 50, (CellContentFrame.Height - 30)/2, 30, 30)); this.CheckMarkIcon.Hidden = true; this.CheckMarkIcon.Image = this.Configuration.CheckMarkImage; this.CheckMarkIcon.ContentMode = UIViewContentMode.ScaleAspectFill; this.ContentView.AddSubview (this.CheckMarkIcon); // Separator for cell var separator = new DropdownMenuTableCellContentView(CellContentFrame); separator.BackgroundColor = UIColor.Clear; this.ContentView.AddSubview (separator); }
public DropdownMenuTableView(CGRect frame, IEnumerable<string> items, DropdownMenuConfiguration configuration) : base(frame, UITableViewStyle.Plain) { var source = new DropwdownMenuTableViewSource(items, configuration); source.ItemSelected += (sender, e) => { if (this.ItemSelected != null) { this.ItemSelected(this, e); } }; this.Source = source; this.BackgroundColor = UIColor.Clear; this.SeparatorStyle = UITableViewCellSeparatorStyle.None; this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; this.TableFooterView = new UIView (CGRect.Empty); }
public DropwdownMenuTableViewSource(IEnumerable<string> items, DropdownMenuConfiguration configuration) { this.items = items; this.selectedItemIndex = 0; this.configuration = configuration; }
public DropdownMenuView(CGRect frame, string title, IEnumerable<string> items, UIView containerView) : base(frame) { // Init properties this.configuration = new DropdownMenuConfiguration(); this.tableContainerView = containerView; this.navigationBarHeight = 44; this.mainScreenBounds = UIScreen.MainScreen.Bounds; this.isShown = false; this.items = items; // Init button as navigation title this.menuButton = new UIButton(frame); this.menuButton.TouchUpInside += MenuButton_TouchUpInside;; this.AddSubview (this.menuButton); this.menuTitle = new UILabel (frame); this.menuTitle.Text = title; this.menuTitle.TextColor = UINavigationBar.Appearance.TitleTextAttributes != null ? UINavigationBar.Appearance.TitleTextAttributes.ForegroundColor : null; this.menuTitle.TextAlignment = UITextAlignment.Center; this.menuTitle.Font = this.configuration.CellTextLabelFont; this.menuButton.AddSubview (this.menuTitle); this.menuArrow = new UIImageView (this.configuration.ArrowImage); this.menuButton.AddSubview (this.menuArrow); // Init table view this.tableView = new DropdownMenuTableView(new CGRect(mainScreenBounds.X, mainScreenBounds.Y, mainScreenBounds.Width, mainScreenBounds.Height + 300 - 64), items, this.configuration); this.tableView.ItemSelected += (sender, e) => { if (this.MenuSelected != null) { this.MenuSelected(this, e); } this.menuTitle.Text = e.Item as string; this.HideMenu(); this.isShown = false; this.LayoutSubviews(); }; }