1.创建_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.设置分页数据(默认0)
_pageControl.numberOfPages = 6;
5.设置当前分页(默认0)
_pageControl.currentPage = 0;
6.没有选中的分页的填充颜色
_pageControl.pageIndicatorTintColor = [UIColor redColor];
7.选中的分页的填充颜色
_pageControl.currentPageIndicatorTintColor = [UIColor yellowColor];
8.关闭用户交互
_pageControl.userInteractionEnabled = NO;
网友评论