Constants for the rendering options for a string when it is drawn.


iOS, tvOS, watchOS
struct NSStringDrawingOptions
struct DrawingOptions



static var usesLineFragmentOrigin: NSStringDrawingOptions

The specified origin is the line fragment origin, not the baseline origin.

static var usesFontLeading: NSStringDrawingOptions

Uses the font leading for calculating line heights.

static var disableScreenFontSubstitution: NSString.DrawingOptions

Disable screen font substitution (equivalent to [NSLayoutManager setUsesScreenFonts:NO]).

static var usesDeviceMetrics: NSStringDrawingOptions

Uses image glyph bounds instead of typographic bounds.

static var oneShot: NSString.DrawingOptions

Suppresses caching layout information.

static var truncatesLastVisibleLine: NSStringDrawingOptions

Truncates and adds the ellipsis character to the last visible line if the text doesn't fit into the bounds specified.


Conforms To

See Also

Sizing and Drawing Strings

func draw(at: CGPoint, withAttributes: [NSAttributedString.Key)

Draws the receiver with the font and other display characteristics of the given attributes, at the specified point in the current graphics context.

func draw(in: CGRect, withAttributes: [NSAttributedString.Key)

Draws the attributed string inside the specified bounding rectangle.

func draw(with: CGRect, options: NSStringDrawingOptions = [], attributes: [NSAttributedString.Key, context: NSStringDrawingContext?)

Draws the attributed string in the specified bounding rectangle using the provided options.

func boundingRect(with: CGSize, options: NSStringDrawingOptions = [], attributes: [NSAttributedString.Key, context: NSStringDrawingContext?) -> CGRect

Calculates and returns the bounding rect for the receiver drawn using the given options and display characteristics, within the specified rectangle in the current graphics context.

func size(withAttributes: [NSAttributedString.Key) -> CGSize

Returns the bounding box size the receiver occupies when drawn with the given attributes.

func variantFittingPresentationWidth(Int) -> String

Returns a string variation suitable for the specified presentation width.