From 99a8d82150b664610396af3f85c98e580a59352b Mon Sep 17 00:00:00 2001 From: Christopher Pickslay Date: Wed, 18 Dec 2013 17:16:25 -0800 Subject: [PATCH 1/2] set attributedText property to allow UILabel to calculate intrinsicContentSize for autolayout --- OHAttributedLabel/Source/OHAttributedLabel.m | 1 + 1 file changed, 1 insertion(+) diff --git a/OHAttributedLabel/Source/OHAttributedLabel.m b/OHAttributedLabel/Source/OHAttributedLabel.m index 7053881..4bbcfae 100755 --- a/OHAttributedLabel/Source/OHAttributedLabel.m +++ b/OHAttributedLabel/Source/OHAttributedLabel.m @@ -737,6 +737,7 @@ -(void)setAttributedText:(NSAttributedString*)newText [self removeAllCustomLinks]; #pragma clang diagnostic pop [self setNeedsRecomputeLinksInText]; + [super setAttributedText:newText]; } From 69accf656a31d806f804f56c645e635b73bac73e Mon Sep 17 00:00:00 2001 From: Dave Roy Date: Wed, 30 Apr 2014 15:49:58 -0700 Subject: [PATCH 2/2] Fix warnings --- OHAttributedLabel/Source/NSAttributedString+Attributes.m | 5 +++-- OHAttributedLabel/Source/OHAttributedLabel.m | 3 ++- OHAttributedLabel/Source/OHTouchesGestureRecognizer.m | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OHAttributedLabel/Source/NSAttributedString+Attributes.m b/OHAttributedLabel/Source/NSAttributedString+Attributes.m index e64f962..a04d84c 100644 --- a/OHAttributedLabel/Source/NSAttributedString+Attributes.m +++ b/OHAttributedLabel/Source/NSAttributedString+Attributes.m @@ -26,6 +26,7 @@ #import "NSAttributedString+Attributes.h" +#import "tgmath.h" #if ! defined(COCOAPODS) && ! defined(OHATTRIBUTEDLABEL_DEDICATED_PROJECT) // Copying files in your project and thus compiling OHAttributedLabel under different build settings @@ -71,7 +72,7 @@ -(CGSize)sizeConstrainedToSize:(CGSize)maxSize fitRange:(NSRange*)fitRange { CFRange fitCFRange = CFRangeMake(0,0); sz = CTFramesetterSuggestFrameSizeWithConstraints(framesetter,CFRangeMake(0,0),NULL,maxSize,&fitCFRange); - sz = CGSizeMake( floorf(sz.width+1) , floorf(sz.height+1) ); // take 1pt of margin for security + sz = CGSizeMake( floor(sz.width+1) , floor(sz.height+1) ); // take 1pt of margin for security CFRelease(framesetter); if (fitRange) @@ -348,7 +349,7 @@ -(void)setCharacterSpacing:(CGFloat)chracterSpacing } -(void)setCharacterSpacing:(CGFloat)chracterSpacing range:(NSRange)range { - [self addAttribute:(NSString *)kCTKernAttributeName value:[NSNumber numberWithFloat:chracterSpacing] range:range]; + [self addAttribute:(NSString *)kCTKernAttributeName value:[NSNumber numberWithDouble:chracterSpacing] range:range]; } -(void)modifyParagraphStylesWithBlock:(void(^)(OHParagraphStyle* paragraphStyle))block diff --git a/OHAttributedLabel/Source/OHAttributedLabel.m b/OHAttributedLabel/Source/OHAttributedLabel.m index 4bbcfae..7e6a256 100755 --- a/OHAttributedLabel/Source/OHAttributedLabel.m +++ b/OHAttributedLabel/Source/OHAttributedLabel.m @@ -28,6 +28,7 @@ #import "OHAttributedLabel.h" #import "CoreTextUtils.h" #import "OHTouchesGestureRecognizer.h" +#import "tgmath.h" #ifndef OHATTRIBUTEDLABEL_WARN_ABOUT_KNOWN_ISSUES #define OHATTRIBUTEDLABEL_WARN_ABOUT_KNOWN_ISSUES 1 @@ -556,7 +557,7 @@ - (void)drawTextInRect:(CGRect)aRect CGSize sz = CTFramesetterSuggestFrameSizeWithConstraints(framesetter,CFRangeMake(0,0),NULL,CGSizeMake(drawingRect.size.width,CGFLOAT_MAX),NULL); if (self.extendBottomToFit) { - CGFloat delta = MAX(0.f , ceilf(sz.height - drawingRect.size.height)) + 10 /* Security margin */; + CGFloat delta = MAX(0.f , ceil(sz.height - drawingRect.size.height)) + 10 /* Security margin */; drawingRect.origin.y -= delta; drawingRect.size.height += delta; } diff --git a/OHAttributedLabel/Source/OHTouchesGestureRecognizer.m b/OHAttributedLabel/Source/OHTouchesGestureRecognizer.m index eb832a1..df490a5 100644 --- a/OHAttributedLabel/Source/OHTouchesGestureRecognizer.m +++ b/OHAttributedLabel/Source/OHTouchesGestureRecognizer.m @@ -26,6 +26,7 @@ #import "OHTouchesGestureRecognizer.h" +#import "tgmath.h" #import @@ -49,7 +50,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint currentPoint = [touch locationInView:self.view]; CGFloat distanceX = (currentPoint.x - _startPoint.x); CGFloat distanceY = (currentPoint.y - _startPoint.y); - CGFloat distance = sqrtf(distanceX * distanceX + distanceY * distanceY); + CGFloat distance = sqrt(distanceX * distanceX + distanceY * distanceY); if (distance > 10.0f) { self.state = UIGestureRecognizerStateCancelled; } else {