use UIPageControl:
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(...)]; // set in header
[pageControl setNumberOfPages:3]
[pageControl setCurrentPage:0]
[pageControl setBackgroundColor:[UIColor clearColor]]
[self.view addSubview:pageControl]
This is a user interface component that shows dots ... the number of pages is the number of dots. The current page is the one currently highlighted.
Then you need to use the scroll delegate method to determine which page scrolls:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
int newOffset = scrollView.contentOffset.x;
int newPage = (int)(newOffset/(scrollView.frame.size.width));
[pageControl setCurrentPage:newPage];
}
source
share