If I'm using a UIScrollView
with a non-zero left/right contentInset
and add a UIRefreshControl
, the refresh is positioned incorrectly making the UI and animation look bizarre.
scrollView.contentInset = UIEdgeInsets(top: 0, left: 40, bottom: 0, right: 40)
scrollView.refreshControl = UIRefreshControl()
I'd prefer not to hack the layout of the refresh control, but can't find a way to get this to position correctly.
Here's a screenshot of the bug:
And here's an animation from the view inspector:
I fixed it locally by creating a UIRefreshControl
subclass, but this is definitely a hack.
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
}
}
I'll file a radar since I'm starting to think this is a bug in UIKit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With