Question : swift paged scrollview get current page
Answered by : rens-wijnmalen
// Swift 5
self.scrollView.delegate = self
// Changed the page property when the user scrolls over 50% of the current page.
// Page starts with 0
func scrollViewDidScroll(_ scrollView: UIScrollView) { let scrollViewWidth = scrollView.bounds.width self.page = Int(round(scrollView.contentOffset.x / scrollViewWidth))
}
var page: Int { didSet { guard oldValue != self.page else { return } // Handle page update }
}
Source : | Last Update : Wed, 26 Jan 22