ARView doesn't seem to work with scaledToFit

It seems like applying .scaleToFit to an ARView object does not resize the view to the correct size. .aspectRatio(contentMode: .fit) also does not work.

Tested on an iPhone 12 Pro, with a project nearly directly derived from the base RealityKit AR project given by Xcode, this results in a square view, rather than one with a 4/3 aspect ratio, which would match the sensor size. When forcing the view to the expected aspect ratio with .aspectRatio(CGSize(width: 3, height: 4), contentMode: .fit), I can confirm that the square is cropped from the 4/3 image, and not the inverse.

This is not a huge deal since it seems all iPhones have 4/3 sensors, but this is annoying. My app needs to let the user see the entire image captured when taking a snapshot, and having to ensure this doesn't break in the future is a bit dull.

Has anyone found a better workaround to this?


Replies

Did you manage to find a fix for this?