 
 public extension Adjustable {
     
+    private var bestContentInset: UIEdgeInsets {
+        let insets: UIEdgeInsets
+        if #available(iOS 11.0, *) {
+            insets = adjustedContentInset
+        } else {
+            insets = contentInset
+        }
+        return insets
+    }
+    
     public func stickHeader() {
         if let stickyView = tableHeaderView {
-            stickyView.frame.origin.y = max(0, contentOffset.y - contentInset.top)
+            stickyView.frame.origin.y = max(0, contentOffset.y + bestContentInset.top)
             // Keep on top, so cells scroll underneath it:
             addSubview(stickyView)
         }


/*
// Implement in a subclass of UITableView:

@IBInspectable open var isStickyHeader: Bool = false
@IBInspectable open var isStickyFooter: Bool = false

    
    public func stickFooter() {
        if let stickyView = tableFooterView {
            stickyView.frame.origin.y = bounds.size.height + contentOffset.y - stickyView.bounds.size.height - bestContentInset.bottom
            // Keep on top, so cells scroll underneath it:
            addSubview(stickyView)
        }
