I'm building a simple photo viewer, with a UIImageView inside a UIScrollView. This should allow zooming and scrolling. When it's zoomed out, the image should be centered in the scrollview.
I've done this before (and having working code), but want to try using the new UIScrollView.contentLayoutGuide property in iOS 11. According to the WWDC videos, this is supposed to simplify centering the view, along these lines:
imageview.centerXAnchor.constraint(equalTo: scrollview.contentLayoutGuide.centerXAnchor)
imageview.centerYAnchor.constraint(equalTo: scrollview.contentLayoutGuide.centerYAnchor)
However, everything I've tried has either failed to center the view (image zooms perfectly but moves to top left when zoomed out), or has centered it with wildly wrong zooming (image starts centered, but when zoomed in moves rapidly past the top left corner of the screen).
Has anyone got this to work, and if so how?