1

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?

user965972
  • 2,489
  • 2
  • 23
  • 39

1 Answers1

1

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];
            }
Metodij Zdravkin
  • 914
  • 1
  • 14
  • 23
  • I know, but this function apparently never gets called. All functions were overridden and past on to super. I never logged a call to this function, on iOS. – user965972 Feb 27 '14 at 12:43