public static int NumberOfLines(this UIFont font, string caption, float width)
{
using (var label = new UILabel())
{
var linefeeds = caption.Count(ch => ch == '\n');
var size = label.StringSize(caption, font);
label.Lines = 1 + ((int)(size.Width / width)) + linefeeds;
if (size.Width % width == 0)
{
label.Lines--;
}
return label.Lines;
}
}