Reputation: 187
I have a UIViewController
containing a scrollView.
The scrollView is pinned (0,0,0,0) to the Safe Area
, this way:
In the body of the viewController viewDidLayoutSubviews
, I add some views to the Content View of this scrollView.
I see no issue in iPhone 6 simulator, but in iPhone X simulator something strange happens: the last view I add to the scrollview goes partially behind the home indicator:
I erroneously thought this was the kind of issue solved by the Safe Area
.
What could I do to solve this issue?
Upvotes: 1
Views: 1622
Reputation: 5378
As of iOS 11 and new iPhone X devices and forward this is the default behavior of safeAreaLayoutGuide.
Scroll view subclasses like table view and collection view handles this problem automatically if you pin the bottom anchor to safe area.
Since you are populating a scroll view manually you need to get the bottom safe area height and inset the scroll view with that value.
You can do it like this:
scrollView.contentInset.bottom = view.safeAreaInsets.bottom
Upvotes: 1
Reputation: 107
Change the ScrollView BottomConstraint related to superviewBottom instead of safeArea.
Upvotes: 0