1,设置scrollView注意一个conteneSize
2,//设置整页滑动
self.myScrollView.pagingEnabled = YES;
//关闭scrollView的弹跳
self.myScrollView.bounces = No;
//关闭水平的滑动条
self.myScrollView.showsHorizontalScrollindicator =NO;
3,布置pageControl
-(void)configPageControl {
//初始化pageController
self.pc = [UIPageControl alloc]init];
//有几个点
self.pc.numberOfPages = 4;
//当前选中的是第几个点 默认不设置是0
self.pc.currentPage = 0;
//每个点的颜色是什么
self.pc.pageIndicatorTintColor = [UIColor whiteColor];
//当前选中的 点的颜色是什么
self.pc.currentPageIndicatorTintColor = [UIColor greenColor];
//关闭用户交互
self.pc.userInteractionEnabled = NO;
//scrollView的代理方法 已经滑动时调用
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
// round 返回的是参数中浮点数 四舍五入 后的值
//当前在第几页上
int currentPageNum = round(scrollView.contentOffset.x / scrollView.frame.size.width);
self.pc.currentPage = currentPageNum;
}