且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取当前页面

更新时间:2023-02-21 15:33:33

There is no UIScrollView property for the current page. You can calculate it with:

int page = scrollView.contentOffset.x / scrollView.frame.size.width;

If you want to round up or down to the nearest page, use:

CGFloat width = scrollView.frame.size.width;
NSInteger page = (scrollView.contentOffset.x + (0.5f * width)) / width;