@@ -2402,7 +2402,9 @@ static void YYTextDrawBorderRects(CGContextRef context, CGSize size, YYTextBorde
2402
2402
// -------------------------- single line ------------------------------//
2403
2403
CGContextSaveGState (context);
2404
2404
for (UIBezierPath *path in paths) {
2405
- CGContextAddRect (context, CGRectMake (0 , 0 , size.width , size.height ));
2405
+ CGRect bounds = CGRectUnion (path.bounds , (CGRect ){CGPointZero , size});
2406
+ bounds = CGRectInset (bounds, -2 * border.strokeWidth , -2 * border.strokeWidth );
2407
+ CGContextAddRect (context, bounds);
2406
2408
CGContextAddPath (context, path.CGPath );
2407
2409
CGContextEOClip (context);
2408
2410
}
@@ -2443,7 +2445,10 @@ static void YYTextDrawBorderRects(CGContextRef context, CGSize size, YYTextBorde
2443
2445
rect = CGRectInset (rect, inset, inset);
2444
2446
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect: rect cornerRadius: border.cornerRadius + 2 * border.strokeWidth];
2445
2447
[path closePath ];
2446
- CGContextAddRect (context, CGRectMake (0 , 0 , size.width , size.height ));
2448
+
2449
+ CGRect bounds = CGRectUnion (path.bounds , (CGRect ){CGPointZero , size});
2450
+ bounds = CGRectInset (bounds, -2 * border.strokeWidth , -2 * border.strokeWidth );
2451
+ CGContextAddRect (context, bounds);
2447
2452
CGContextAddPath (context, path.CGPath );
2448
2453
CGContextEOClip (context);
2449
2454
}
0 commit comments