public virtual nfloat GetHeight(UITableView tableView, NSIndexPath indexPath) { var size = new CGSize(280, float.MaxValue); using (var font = UIFont.FromName("Helvetica", 17f)) return(Caption.StringSize(font, size, UILineBreakMode.WordWrap).Height + 10); }
public nfloat GetHeight(UITableView tableView, NSIndexPath indexPath) { CGSize size = new CGSize(tableView.Bounds.Width - 40, nfloat.MaxValue); nfloat height = Caption.StringSize(Font, size, LineBreakMode).Height + 10; // Image is 57 pixels tall, add some padding return((nfloat)Math.Max(height, 63)); }
public virtual nfloat GetHeight(UITableView tableView, NSIndexPath indexPath) { var maxSize = new CGSize(tableView.Bounds.Width - 40, float.MaxValue); if (this.Accessory != UITableViewCellAccessory.None) { maxSize.Width -= 20; } var captionFont = Font ?? UIFont.BoldSystemFontOfSize(17); nfloat height = Caption.StringSize(captionFont, maxSize, LineBreakMode).Height; if ((this.Style == UITableViewCellStyle.Subtitle) && !String.IsNullOrEmpty(Value)) { var subtitleFont = SubtitleFont ?? UIFont.SystemFontOfSize(14); height += Value.StringSize(subtitleFont, maxSize, LineBreakMode).Height; } return(height + 10); }
protected override void UpdateCaptionDisplay(UITableViewCell cell) { if (cell == null) { return; } if (Caption != null && ShowCaption) { cell.TextLabel.Text = Caption; _captionSize = Caption.StringSize(UIFont.FromName(cell.TextLabel.Font.Name, UIFont.LabelFontSize)); _captionSize.Width += 10; // Spacing } else { _captionSize = new CGSize(0, 0); } if (_slider != null) { _slider.Frame = GetSliderRectangle(); } }
public override UITableViewCell GetCell(UITableView tv) { var cell = tv.DequeueReusableCell(CellKey); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellKey); cell.SelectionStyle = UITableViewCellSelectionStyle.None; } else RemoveTag(cell, 1); var captionSize = new CGSize(0, 0); if (Caption != null && ShowCaption) { cell.TextLabel.Text = Caption; captionSize = Caption.StringSize(UIFont.FromName(cell.TextLabel.Font.Name, UIFont.LabelFontSize)); captionSize.Width += 10; // Spacing } if (slider == null) { slider = new UISlider(new CGRect(10f + captionSize.Width, UIDevice.CurrentDevice.CheckSystemVersion(7, 0) ? 18f : 12f, cell.ContentView.Bounds.Width - 20 - captionSize.Width, 7f)) { BackgroundColor = UIColor.Clear, MinValue = this.MinValue, MaxValue = this.MaxValue, Continuous = true, Value = this.Value, Tag = 1, AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; slider.ValueChanged += delegate { Value = (int)slider.Value; this.AnswerText = Value.ToString(); Caption = Value.ToString(); captionSize = Caption.StringSize(UIFont.FromName(cell.TextLabel.Font.Name, UIFont.LabelFontSize)); captionSize.Width += 10; // Spacing cell.TextLabel.Text = Caption; slider.Frame = new CGRect(10f + captionSize.Width, UIDevice.CurrentDevice.CheckSystemVersion(7, 0) ? 18f : 12f, cell.ContentView.Bounds.Width - 20 - captionSize.Width, 7f); }; } else { slider.Value = Value; } cell.ContentView.AddSubview(slider); cell.UserInteractionEnabled = Enabled; cell.TextLabel.TextColor = UIColor.Black; //cell.TextLabel.Font = UIFont.BoldSystemFontOfSize(17); cell.BackgroundColor = UIColor.White; if (!Enabled) { cell.TextLabel.TextColor = UIColor.LightGray; cell.BackgroundColor = UIColor.GroupTableViewBackgroundColor; } return cell; }