Instance Method


Fills background rectangles with a color.


iOS, Mac Catalyst, tvOS
- (void)fillBackgroundRectArray:(const CGRect *)rectArray count:(NSUInteger)rectCount forCharacterRange:(NSRange)charRange color:(UIColor *)color;
- (void)fillBackgroundRectArray:(const NSRect *)rectArray count:(NSUInteger)rectCount forCharacterRange:(NSRange)charRange color:(NSColor *)color;



The array of rectangles to fill.


The number of rectangles in rectArray.


The range of characters whose background rectangles are filled.


The fill color.


This is the primitive method used by drawBackgroundForGlyphRange:atPoint:, providing a finer-grained override point for actually filling rectangles with a particular background color for a background color attribute, a selected or marked range highlight, a block decoration, or any other rectangle fill needed by that method. As with showPackedGlyphs:length:glyphRange:atPoint:font:color:printingAdjustment:, the charRange and color parameters are passed in merely for informational purposes; the color is already set in the graphics state. If for any reason you modify it, you must restore it before returning from this method.

This method operates in terms of character ranges, because the relevant attributes are expressed on characters, and they don't always lie on glyph boundaries—for example, when one character of an “fi” ligature is highlighted.

You should never call this method, but you might override it. The default implementation simply fills the rectangles in the specified array. The graphics operation used for this fill is controlled by a link check; for compatibility reasons, it is NSCompositeCopy for applications linked prior to OS X v10.6 and NSCompositeSourceOver for applications linked on macOS 10.6 or later. Applications can control the operation used, or modify the drawing, by overriding this method in an NSLayoutManager subclass.

See Also


- drawBackgroundForGlyphRange:atPoint:

Draws background marks for the specified glyphs, which must lie completely within a single text container.

- drawGlyphsForGlyphRange:atPoint:

Draws the specified glyphs, which must lie completely within a single text container.

- showCGGlyphs:positions:count:font:textMatrix:attributes:inContext:

Renders the glyphs at the specified positions, using the specified attributes.

- underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:

Calculates subranges to be underlined for the specified glyphs and draws the underlining as appropriate.

Glyph Attributes

Attributes that are used only inside the glyph generation machinery, but must also be shared between components.