MonoMobile.Views.BaseDialogViewSource.GetHeightForHeader C# (CSharp) Method

GetHeightForHeader() public method

public GetHeightForHeader ( UITableView tableView, int sectionIndex ) : float
tableView UITableView
sectionIndex int
return float
		public override float GetHeightForHeader(UITableView tableView, int sectionIndex)
		{
			if (Sections.Count > sectionIndex && Sections.ContainsKey(sectionIndex))
			{
				var section = Sections[sectionIndex];
				
				if (section != null && !string.IsNullOrEmpty(section.HeaderText))
				{
					var indentation = UIDevice.CurrentDevice.GetIndentation();
					var width = tableView.Bounds.Width - (indentation * 2);
					
					using (var headerLabel = new UILabel())
					{
						headerLabel.Font = UIFont.BoldSystemFontOfSize(UIFont.LabelFontSize);
						var size = headerLabel.StringSize(section.HeaderText, headerLabel.Font);
					
						var height = (float)Math.Floor((float)(size.Height * (headerLabel.Font.NumberOfLines(section.HeaderText, width) + 0.5))) + 1;
						
						return height;
					}
				}
			}
			return 0;
		}