size(withAttributes:)
Returns the bounding box size the receiver occupies when drawn with the given attributes.
Declaration
func size(withAttributes attrs: [NSAttributedString.Key : Any]? = nil) -> CGSizeParameters
- attrs:
A dictionary of text attributes to be applied to the string. These are the same attributes that can be applied to an
NSAttributedStringobject, but in the case ofNSStringobjects, the attributes apply to the entire string, rather than ranges within the string.
Return Value
The bounding box size the receiver occupies when drawn with the specified attributes.
Discussion
This method returns fractional sizes; to use a returned size to size views, you must raise its value to the nearest higher integer using the ceil function.