Open tinder-cfuller opened 1 year ago
Left margin is not respected in view controller snapshot images on iPhone 8/SE in landscape even though the left margin is reflected in the recursive description (and respected when running the app in the simulator).
Sample.zip
class ViewController: UIViewController { let blueView: UIView = { let view = UIView() view.backgroundColor = .blue view.translatesAutoresizingMaskIntoConstraints = false return view }() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemBackground view.addSubview(blueView) NSLayoutConstraint.activate([ blueView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor), blueView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor), blueView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), blueView.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.bottomAnchor) ]) } }
final class SampleTests: XCTestCase { func testViewController() throws { let device: ViewImageConfig = .iPhone8(.landscape) let vc = ViewController() assertSnapshot(matching: vc, as: .recursiveDescription(on: device)) assertSnapshot(matching: vc, as: .image(on: device)) } }
The left margin of 20 is reflected in the x of the frame.
x
frame
<UIView; frame = (20 0; 627 375); backgroundColor = UIExtendedSRGBColorSpace 0 0 1 1; layer = <CALayer>>
The left margin is incorrectly not respected.
The left margin should be correctly respected in view controller snapshot images on iPhone 8/SE in landscape.
For example, the left margin is respected when running the app in the simulator.
1.11.1
14.3.1
5.8
iOS 16.4
I just tested the above ☝️ proposed fix in the sample app attached to this issue and it worked 👍
Thank you @leohemanth!
Describe the bug
Left margin is not respected in view controller snapshot images on iPhone 8/SE in landscape even though the left margin is reflected in the recursive description (and respected when running the app in the simulator).
To Reproduce
Sample Project:
Sample.zip
View Controller:
Test:
Recursive Description:
The left margin of 20 is reflected in the
x
of theframe
.Snapshot Image:
The left margin is incorrectly not respected.
Expected behavior
The left margin should be correctly respected in view controller snapshot images on iPhone 8/SE in landscape.
For example, the left margin is respected when running the app in the simulator.
Simulator Screenshot:
Environment
1.11.1
14.3.1
5.8
iOS 16.4