MonoTouch.UIKit.UIView.StringSize Method

Deprecated in iOS7. Use NSString.GetBoundingRect (SizeF, NSStringDrawingOptions, UIStringAttributes,NSStringDrawingContext) instead.

Calculates the System.Drawing.SizeF of the specified string if it were rendered with the specified: font, size constraint, and line-break mode.

Syntax

[MonoTouch.ObjCRuntime.ThreadSafe]
public System.Drawing.SizeF StringSize (string str, UIFont font, System.Drawing.SizeF constrainedToSize, UILineBreakMode lineBreakMode)

Parameters

str
The string whose size is being calculated.
font
The font to be used in the size calculation.
constrainedToSize
The maximum System.Drawing.SizeF allowed for the string.
lineBreakMode
The line-break mode to be used in the calculation.

Returns

Returns the System.Drawing.SizeF of the specified string if it were rendered with the specified: font, size constraint, and line-break mode.

Remarks

Application developers can use this method to calculate text metrics. It does not render or otherwise change state in the MonoTouch.UIKit.UIView.

This method calculates the size that the str would require if rendered with the font, but if it the rendering were not allowed to exceed the dimensions of the constrainedToSizeSystem.Drawing.SizeF. This method calculates the size using the specified lineBreakMode line-break mode. If the calculated size exceeds the available dimensions, the method will attempt to truncate the string internally and return a System.Drawing.SizeF based on that truncated text. If the System.Drawing.SizeF.Height of the constrainedToSize argument is less than that of a single line of text in the specfied font, the method may return a System.Drawing.SizeF whose System.Drawing.SizeF.Height is greater than that in constrainedToSize.

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0