I was using this in Objective-C when I had a Navigation Bar in my UIView and had good results for iOS 10.
In case you use SafeArea in your xib then you may add in your viewDidLoad:
if (@available(iOS 11.0, *)) {}
else {
self.edgesForExtendedLayout = UIRectEdgeNone;
}