Skip to content

Commit f6a2ae9

Browse files
committed
Fixed issue where subviews of UIScrollView would be placed incorrectly in snapshot
1 parent a0b5036 commit f6a2ae9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

InAppViewDebugger/ViewElement.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import UIKit
2323
}
2424

2525
public var frame: CGRect {
26-
return view?.frame ?? .zero
26+
let offset = contentOffsetForView(view)
27+
return view?.frame.offsetBy(dx: offset.x, dy: offset.y) ?? .zero
2728
}
2829

2930
public var isHidden: Bool {
@@ -155,3 +156,9 @@ fileprivate func snapshotView(_ view: UIView) -> CGImage? {
155156
}
156157
return image
157158
}
159+
160+
fileprivate func contentOffsetForView(_ view: UIView?) -> CGPoint {
161+
guard let scrollView = view?.superview as? UIScrollView else { return .zero }
162+
let contentOffset = scrollView.contentOffset
163+
return CGPoint(x: -contentOffset.x, y: -contentOffset.y)
164+
}

0 commit comments

Comments
 (0)