带有左/右 contentInset 的 UIScrollView 中的 UIRefreshControl 布局错误

rny*_*rom 5 uitableview uiscrollview uikit uicollectionview uirefreshcontrol

如果我使用UIScrollView带有非零左/右的 acontentInset并添加 a UIRefreshControl,则刷新位置不正确,使 UI 和动画看起来很奇怪。

scrollView.contentInset = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 40)
scrollView.refreshControl = UIRefreshControl()
Run Code Online (Sandbox Code Playgroud)

我不想破坏刷新控件的布局,但找不到使其正确定位的方法。

这是错误的屏幕截图: 在此处输入图片说明

这是来自视图检查器的动画:

在此处输入图片说明

rny*_*rom 5

我通过创建一个UIRefreshControl子类在本地修复了它,但这绝对是一个黑客。

override var frame: CGRect {
    get { return super.frame }
    set {
        var newFrame = newValue
        if let superScrollView = superview as? UIScrollView {
            newFrame.origin.x = superScrollView.frame.minX - superScrollView.contentInset.left
        }
        super.frame = newFrame
    }
}
Run Code Online (Sandbox Code Playgroud)

我将提交雷达,因为我开始认为这是 UIKit 中的一个错误。