Instance Method

drawBackground(forGlyphRange:at:)

Draws background marks for the given glyph range, which must lie completely within a single text container.

Declaration

iOS, Mac Catalyst, tvOS
func drawBackground(forGlyphRange glyphsToShow: NSRange, at origin: CGPoint)
macOS
func drawBackground(forGlyphRange glyphsToShow: NSRange, at origin: NSPoint)

Parameters

glyphsToShow

The range of glyphs for which the background is drawn.

origin

The position of the text container in the coordinate system of the currently focused view.

Discussion

This method is called by NSTextView for drawing. You can override it to perform additional drawing, or to replace text drawing entirely, but not to change layout. You can call this method directly, but focus must already be locked on the destination view or image.

Background marks are such things as selection highlighting, text background color, and any background for marked text, along with block decoration such as table backgrounds and borders.

Performs glyph generation and layout if needed.

See Also

Drawing

func drawGlyphs(forGlyphRange: NSRange, at: CGPoint)

Draws the glyphs in the given glyph range, which must lie completely within a single text container.

func underlineGlyphRange(NSRange, underlineType: NSUnderlineStyle, lineFragmentRect: CGRect, lineFragmentGlyphRange: NSRange, containerOrigin: CGPoint)

Calculates subranges to be underlined for the glyphs in a given range and draws the underlining as appropriate.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software