From 40b4f3226b735829d6b04f7e43f7cb286b904183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B8=CC=86=20=D0=9B=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D1=80=D0=B5=D0=B2?= Date: Mon, 4 Mar 2013 14:27:25 +0600 Subject: [PATCH] Fix issue #34 --- OHAttributedLabel/Source/OHAttributedLabel.m | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) 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