- 在UIScrollView中
// 获得页码
CGFloat doublePage = scrollView.contentOffset.x / scrollView.width;
int intPage = (int)(doublePage + 0.5);
// 设置页码
self.pageControl.currentPage = intPage;
- 在UICollectionView中
NSIndexPath *visiablePath = [[collectionView indexPathsForVisibleItems] firstObject];
self.title = [NSString stringWithFormat:@"%ld / %ld", ((visiablePath.item % self.imageArrayM.count)) + 1, self.imageArrayM.count];
网友评论