Draws the receiver with the font and other display characteristics of the given attributes, at the specified point in the current graphics context.
- iOS 7.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The point in the current graphics context where you want to start drawing the string. The coordinate system of the graphics context is usually defined by the view in which you are drawing. In AppKit, the origin is normally in the lower-left corner of the drawing area, but the origin is in the upper-left corner if the focused view is flipped.
A dictionary of text attributes to be applied to the string. These are the same attributes that can be applied to an
NSAttributedobject, but in the case of
NSStringobjects, the attributes apply to the entire string, rather than ranges within the string.
The width (height for vertical layout) of the rendering area is unlimited, unlike
draw(in:, which uses a bounding rectangle. As a result, this method renders the text in a single line. However, if newline characters are present in the string, those characters are honored and cause subsequent text to be placed on the next line underneath the starting point.
There must be either a focused view or an active graphics context when you call this method.