'automaticallyAdjustsScrollViewInsets' was deprecated in iOS 11.0

You can also set this in Interface Builder. Select your tableView or collectionView then select from the drop-down in the Size Inspector select .never for 'Content Insets Adjustment Behavior'

Size Inspector


The default for this property is now true. If you need to set this, you will need to set it in the scrollview that would host the viewController and set its property contentInsetAdjustmentBehavior. Below is an example:

scrollView.contentInsetAdjustmentBehavior = .automatic

This code may help:

if #available(iOS 11.0, *) {
    scrollView.contentInsetAdjustmentBehavior = .never
} else {
    automaticallyAdjustsScrollViewInsets = false
}