Skip to content

Commit

Permalink
fix text border draw defect when the border out of the view's bounds: i…
Browse files Browse the repository at this point in the history
  • Loading branch information
ibireme committed May 27, 2016
1 parent 42bef57 commit dcd64b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions YYText/Component/YYTextLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,9 @@ static void YYTextDrawBorderRects(CGContextRef context, CGSize size, YYTextBorde
//-------------------------- single line ------------------------------//
CGContextSaveGState(context);
for (UIBezierPath *path in paths) {
CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));
CGRect bounds = CGRectUnion(path.bounds, (CGRect){CGPointZero, size});
bounds = CGRectInset(bounds, -2 * border.strokeWidth, -2 * border.strokeWidth);
CGContextAddRect(context, bounds);
CGContextAddPath(context, path.CGPath);
CGContextEOClip(context);
}
Expand Down Expand Up @@ -2443,7 +2445,10 @@ static void YYTextDrawBorderRects(CGContextRef context, CGSize size, YYTextBorde
rect = CGRectInset(rect, inset, inset);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:border.cornerRadius + 2 * border.strokeWidth];
[path closePath];
CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));

CGRect bounds = CGRectUnion(path.bounds, (CGRect){CGPointZero, size});
bounds = CGRectInset(bounds, -2 * border.strokeWidth, -2 * border.strokeWidth);
CGContextAddRect(context, bounds);
CGContextAddPath(context, path.CGPath);
CGContextEOClip(context);
}
Expand Down

0 comments on commit dcd64b2

Please sign in to comment.