This may be a simple problem. I have a UIScrollView with 3 views. I need to display 3 dots like Indicator ( to indicate there are more pages to the user). How do i do this?
use a UIPageControl:
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(...)]; // set in header
[pageControl setNumberOfPages:3];
[pageControl setCurrentPage:0];
[pageControl setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:pageControl];
That is the UI component that shows the dots... the number of pages is the number of dots. The current page is the one that is currently highlighted.
Then you need to use the scroll view delegate method to determine what page you've scrolled to:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
int newOffset = scrollView.contentOffset.x;
int newPage = (int)(newOffset/(scrollView.frame.size.width));
[pageControl setCurrentPage:newPage];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With