Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions OHAttributedLabel/Source/NSAttributedString+Attributes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion OHAttributedLabel/Source/OHAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -737,6 +738,7 @@ -(void)setAttributedText:(NSAttributedString*)newText
[self removeAllCustomLinks];
#pragma clang diagnostic pop
[self setNeedsRecomputeLinksInText];
[super setAttributedText:newText];
}


Expand Down
3 changes: 2 additions & 1 deletion OHAttributedLabel/Source/OHTouchesGestureRecognizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


#import "OHTouchesGestureRecognizer.h"
#import "tgmath.h"

#import <UIKit/UIGestureRecognizerSubclass.h>

Expand All @@ -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 {
Expand Down