mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 21:41:45 +00:00
Fix text highlighting in UIScrollView
Highlight target layers with non-zero bounds.origin exhibited broken text highlighting behavior. Highlights would appear offset by the layer’s bounds.origin, and would not align with their target text. This most often appeared in UIScrollView, where highlights would appear incorrectly offset once the scroll view was scrolled. Fix by accounting for bounds.origin in the calculations of the text overlay highlight rects.
This commit is contained in:
parent
bd30f975ab
commit
9d866f63e3
@ -554,6 +554,12 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
||||
for (NSValue *rectValue in highlightRects) {
|
||||
CGRect rendererRect = [[self class] _adjustRendererRect:rectValue.CGRectValue forShadowPadding:_shadower.shadowPadding];
|
||||
CGRect highlightedRect = [self.layer convertRect:rendererRect toLayer:highlightTargetLayer];
|
||||
|
||||
// We set our overlay layer's frame to the bounds of the highlight target layer.
|
||||
// Offset highlight rects to avoid double-counting target layer's bounds.origin.
|
||||
highlightedRect.origin.x -= highlightTargetLayer.bounds.origin.x;
|
||||
highlightedRect.origin.y -= highlightTargetLayer.bounds.origin.y;
|
||||
|
||||
[converted addObject:[NSValue valueWithCGRect:highlightedRect]];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user