CarouselView.FormsPlugin.iOS.TextMeterImplementation.MeasureTextSize C# (CSharp) Method

MeasureTextSize() public method

public MeasureTextSize ( string text, double width, double fontSize, string fontName = null ) : double
text string
width double
fontSize double
fontName string
return double
		public double MeasureTextSize(string text, double width, double fontSize, string fontName = null)
		{
			var nsText = new NSString(text);
			var boundSize = new SizeF((float)width, float.MaxValue);
			var options = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin;

			if (fontName == null)
			{
				fontName = "HelveticaNeue";
			}

			var attributes = new UIStringAttributes
			{
				Font = UIFont.FromName(fontName, (float)fontSize)
			};

			var sizeF = nsText.GetBoundingRect(boundSize, options, attributes, null).Size;

			return (double)sizeF.Height + 5;
		}
	}
TextMeterImplementation