 
         switch style {
         case .header:
-            progress = min(1, max(0, -(scrollView.contentOffset.y + scrollView.contentInset.top) / height))
+            progress = min(1, max(0, -(scrollView.contentOffset.y + scrollView.contentInsetTop) / height))
         case .footer:
             if scrollView.contentSize.height <= scrollView.bounds.height { break }
-            progress = min(1, max(0, (scrollView.contentOffset.y + scrollView.bounds.height - scrollView.contentSize.height - scrollView.contentInset.bottom) / height))
+            progress = min(1, max(0, (scrollView.contentOffset.y + scrollView.bounds.height - scrollView.contentSize.height - scrollView.contentInsetBottom) / height))
         case .autoFooter:
             if scrollView.contentSize.height <= scrollView.bounds.height { break }
-            if scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.bounds.height + scrollView.contentInset.bottom {
+            if scrollView.contentOffset.y > scrollView.contentSize.height - scrollView.bounds.height + scrollView.contentInsetBottom {
                 beginRefreshing()
             }
         }

            UIView.animate(withDuration: 0.3, animations: {
                switch self.style {
                case .header:
                    scrollView.contentOffset.y = -self.height - scrollView.contentInset.top
                    scrollView.contentInset.top += self.height
                case .footer:
                    scrollView.contentInset.bottom += self.height
                case .autoFooter:
                    scrollView.contentOffset.y = self.height + scrollView.contentSize.height - scrollView.bounds.height + scrollView.contentInset.bottom
                    scrollView.contentInset.bottom += self.height
                }
            }, completion: { _ in

    }

}

private extension UIScrollView {
    var contentInsetTop: CGFloat {
        if #available(iOS 11.0, *) {
            return contentInset.top + adjustedContentInset.top
        } else {
            return contentInset.top
        }
    }

    var contentInsetBottom: CGFloat {
        if #available(iOS 11.0, *) {
            return contentInset.bottom + adjustedContentInset.bottom
        } else {
            return contentInset.bottom
        }
    }
}
