Structure

NSStringDrawingOptions

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

Declaration

iOS, tvOS, watchOS
struct NSStringDrawingOptions
macOS
struct DrawingOptions

Topics

Constants

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]).

Deprecated
static var usesDeviceMetrics: NSStringDrawingOptions

Uses image glyph bounds instead of typographic bounds.

static var oneShot: NSString.DrawingOptions

Suppresses caching layout information.

Deprecated
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.

Relationships

Conforms To

See Also

Sizing and Drawing Strings

func draw(at: CGPoint, withAttributes: [NSAttributedString.Key : Any]? = nil)

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 : Any]? = nil)

Draws the attributed string inside the specified bounding rectangle.

func boundingRect(with: CGSize, options: NSStringDrawingOptions = [], attributes: [NSAttributedString.Key : Any]? = nil, 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 : Any]? = nil) -> 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.