The most obvious solution is to forbid y-coordinate changes in your subclass.
override var contentOffset: CGPoint {
get {
return super.contentOffset
}
set {
super.contentOffset = CGPoint(x: newValue.x, y: 0)
}
}
This is the only suitable solution in situations when: