diff --git a/OHAttributedLabel/Source/OHAttributedLabel.m b/OHAttributedLabel/Source/OHAttributedLabel.m index d1ecbc4..3000311 100755 --- a/OHAttributedLabel/Source/OHAttributedLabel.m +++ b/OHAttributedLabel/Source/OHAttributedLabel.m @@ -552,6 +552,32 @@ - (void)drawTextInRect:(CGRect)aRect { CFAttributedStringRef cfAttrStrWithLinks = (BRIDGE_CAST CFAttributedStringRef)attributedStringToDisplay; CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(cfAttrStrWithLinks); + + if (self.numberOfLines>0) { + CGMutablePathRef path = CGPathCreateMutable(); + CGPathAddRect(path, NULL, self.bounds); + + CTFrameRef frame = CTFramesetterCreateFrame(framesetter,CFRangeMake(0,0), path, NULL); + CFArrayRef lines = CTFrameGetLines(frame); + + if(CFArrayGetCount(lines) > self.numberOfLines) { + CFIndex length=0; + for (CFIndex i=0; i