1.創(chuàng)建_pageControl對象
UIPageControl 繼承 UIControl
CGFloat PX = 0;
CGFloat PH = 20;
CGFloat PY = _scrollView.frame.size.height - PH;
CGFloat PW = _scrollView.frame.size.width;
UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(PX, PY, PW, PH)];
2.顯示在界面上
[self.view addSubview:_pageControl];
3.設置背景顏色
_pageControl.backgroundColor = [UIColor blackColor];
_pageControl.alpha = 0.5f;
核心設置
4.設置分頁數(shù)據(jù)(默認0)
_pageControl.numberOfPages = 6;
5.設置當前分頁(默認0)
_pageControl.currentPage = 0;
6.沒有選中的分頁的填充顏色
_pageControl.pageIndicatorTintColor = [UIColor redColor];
7.選中的分頁的填充顏色
_pageControl.currentPageIndicatorTintColor = [UIColor yellowColor];
8.關閉用戶交互
_pageControl.userInteractionEnabled = NO;