What’s new on scrollView?

Published by

on

In Xcode 11, the scroll view has two new things, which are the Content Layout Guide and Frame Layout Guide.

It’s a very convenient way to set content size for scrollView.

Let’s check how to use it on the storyboard.

scrollView.png

What is the Content Layout Guide?

It is the size of the content. For example, if your scrollView is enabled vertical scrolling only, then set the subviews constraints relative to the Content Layout Guide.

viewConstraintStep1.png

viewConstraintStep2.png

What is the Frame Layout Guide?

It is a fixed size of the content. For example, if scrollView is enabled vertical only, then just set the Frame Layout Guide’s width constraint and leave your height constraint.

viewConstraintStep3.png

How to resolve the constraint warnings?

The above steps is an essential for scrollView with its subView. However Storyboard may still complain.

constraintProblem.png

To solve the constraint issue, change the intrinsic size of the scroll views subView.

constraintSolve.png

Add stackView

For scrolling the contents, I added stackView with listViews.

scrolling.gif

Thanks for reviewing my post

Shai Mishali

Navati is having tea

Bart Pang