I was trying to add a sticky header to my scroll view in swift. While I searched, I found an example and I implemented as follows:
override func viewDidLoad() {
super.viewDidLoad()
self.m_scrlvwMAinScroll.delegate = self
self.initialOffSet = self.m_vwAnchorVw.frame.origin.y
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
var newFrame = self.m_vwAnchorVw.frame
newFrame.origin.y = max(self.initialOffSet, scrollView.contentOffset.y)
self.m_vwAnchorVw.frame = newFrame
}
But here the sticky view (self.m_vwAnchorVw) though stood at the top while scrolling, the other scrollview contents was scrolling over the sticky view not below the view.
I want the scrollview contents to scroll below the sticky view when scrolled up.
What change should I make in the code?