uiscrollview safe area code example

Example: uiscrollview safe area

This spacing is from safe area, which is applied to left/right of UIScrollview as content insets in landscape orientation on iPhone X, which can be seen using read-only property UIScrollview.safeAreaInsets.

Following line can be used to get rid of safe area insets when you dont need:

UIScrollview.contentInsetAdjustmentBehavior = .never

The default value being UIScrollViewContentInsetAdjustmentBehavior.automatic includes safe area layout guide margins as content insets.

Note: auto layout constraints has nothing to do with the insets, its just iOS 11 UIScrollview content insets adjustment behavior.

Tags:

Misc Example