From d582457794a6eb44fdc70387abde938f8edf59cf Mon Sep 17 00:00:00 2001 From: Wilsonator5000 Date: Sun, 28 Jan 2018 14:49:05 -0500 Subject: [PATCH] Make links more tappable by increasing the bounding box Added 7.5pt legroom around the bounding box so the user has more space to tap the link. --- TSLabel/TSLabel.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TSLabel/TSLabel.m b/TSLabel/TSLabel.m index c0d1c54..a9fb7c8 100644 --- a/TSLabel/TSLabel.m +++ b/TSLabel/TSLabel.m @@ -71,7 +71,8 @@ - (void) layoutManager: (NSLayoutManager *) layoutManager didCompleteLayoutForTe NSRange glyphRange = [layoutManager glyphRangeForCharacterRange: range actualCharacterRange: nil]; CGRect bounds = [layoutManager boundingRectForGlyphRange: glyphRange inTextContainer: textContainer]; - link.bounds = CGRectOffset(bounds, 0, (label.bounds.size.height-containerGlyphBounds.size.height)/2); + CGRect boundsOffset = CGRectOffset(bounds, 0, (label.bounds.size.height-containerGlyphBounds.size.height)/2); + link.bounds = CGRectMake(boundsOffset.origin.x - 7.5, boundsOffset.origin.y - 7.5, boundsOffset.size.width + 15, boundsOffset.size.height + 15); // Make links more tappable by increasing the bounding box [links addObject: link]; } @@ -239,4 +240,4 @@ - (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event [self setAttributedText: self.attributedText]; } -@end \ No newline at end of file +@end