A simple to use drop in replacement for UILabel for iOS 7 and above that highlights links such as URLs, twitter style usernames and hashtags and makes them touchable.
- (void)drawTextInRect:(CGRect)rect
{
// Don't call super implementation. Might want to uncomment this out when
// debugging layout and rendering problems.
// [super drawTextInRect:rect];
// Calculate the offset of the text in the view
NSRange glyphRange = [_layoutManager glyphRangeForTextContainer:_textContainer];
CGPoint glyphsPosition = [self calcGlyphsPositionInView];
// Drawing code
[_layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:glyphsPosition];
[_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:glyphsPosition];
}
Have U done some performance test ?
When I use KILabel in my tableview cell, it have a damage impact on performance,especially [_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:glyphsPosition]; the tool , timer profile of Instruments shows it takes 27% of whole-time,which bring a significant delay when I scroll my tableview.
I am trying to improve it. I sincerely hope that U can do better modification.
Hi, Krelborn, When you use
Have U done some performance test ? When I use KILabel in my tableview cell, it have a damage impact on performance,especially
[_layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:glyphsPosition];
the tool , timer profile of Instruments shows it takes 27% of whole-time,which bring a significant delay when I scroll my tableview.I am trying to improve it. I sincerely hope that U can do better modification.