Instance Method

size

Returns the size required to draw the string.

Declaration

iOS, Mac Catalyst, tvOS, watchOS
- (CGSize)size;
macOS
- (NSSize)size;

Return Value

The minimum size required to draw the entire contents of the string.

Discussion

You can use this method prior to drawing to compute how much space is required to draw the string.

This method may return fractional sizes. When setting the size of your view, use the ceil function to round fractional values up to the nearest whole number.

See Also

Getting Metrics for the String

- boundingRectWithSize:options:context:

Returns the bounding rectangle required to draw the string.

- containsAttachmentsInRange:

Returns a Boolean value that indicates if the attributed string contains a property configured in the specified range.