Skip to content

Commit

Permalink
[attributedlabel] Decrease the radius of the attributed label highlig…
Browse files Browse the repository at this point in the history
…ht rect.

This ensures that the attributed label's highlight rect doesn't bleed past the bounds of the view.
  • Loading branch information
jverkoey committed Nov 20, 2012
1 parent d816b57 commit df64cc0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/attributedlabel/src/NIAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,10 @@ - (CGRect)_rectForRange:(NSRange)range inLine:(CTLineRef)line lineOrigin:(CGPoin

CGRect linkRect = CGRectMake(lineOrigin.x + xOffset - leading, lineOrigin.y - descent, width + leading, height);

linkRect = CGRectIntegral(linkRect);
linkRect = CGRectInset(linkRect, -2, 0);
linkRect.origin.y = roundf(linkRect.origin.y);
linkRect.origin.x = roundf(linkRect.origin.x);
linkRect.size.width = roundf(linkRect.size.width);
linkRect.size.height = roundf(linkRect.size.height);

if (CGRectIsEmpty(rectForRange)) {
rectForRange = linkRect;
Expand Down Expand Up @@ -1319,7 +1321,7 @@ - (void)drawHighlightWithRect:(CGRect)rect {
if (!CGRectIsEmpty(highlightRect)) {
CGFloat pi = (CGFloat)M_PI;

CGFloat radius = 5.0f;
CGFloat radius = 1.0f;
CGContextMoveToPoint(ctx, highlightRect.origin.x, highlightRect.origin.y + radius);
CGContextAddLineToPoint(ctx, highlightRect.origin.x, highlightRect.origin.y + highlightRect.size.height - radius);
CGContextAddArc(ctx, highlightRect.origin.x + radius, highlightRect.origin.y + highlightRect.size.height - radius,
Expand Down

0 comments on commit df64cc0

Please sign in to comment.