0
votes

How is the function drawGlyphsForGlyphRange:atPoint: in the class NSLayoutManager implemented? I know it's called by NSTextView and in turn calls fillBackgroundRectArray:count:forCharacterRange:color:

But how does it determine the backgroundcolor, if any, for the specified glyphrange?

1

1 Answers

0
votes

You have another call for glyph background. You can use

- (void)drawBackgroundForGlyphRange:(NSRange)glyphsToShow atPoint:(CGPoint)origin;

UPDATE:

I use it like this in drawRect in UIView.

 NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
            if (glyphRange.location != NSNotFound)
            {
                [layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:label.frame.origin];                
                [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:label.frame.origin];
            }