UIPageControl *page=[[UIPageControl alloc]init];
scroll.frame =self.view.bounds;
//靠中间的控件一般用center
page.center =CGPointMake(size.width*0.5, size.height*0.95);
//控件高度为固定值所以为0
page.bounds =CGRectMake(0, 0, 150, 0);
//分页页数
page.numberOfPages =4;
//当前选中page添加背景图片
page.currentPageIndicatorTintColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@“XXX.png"]];
//普通颜色
page.pageIndicatorTintColor=[UIColor blueColor];
想让它滚动得加代理:
1.UIScrollView *scroll=[[UIScrollView alloc]init];
scroll.delegate =self;
2.在.h或.m开头加上<UIScrollViewDeldgate>
3.将page变成全局变量,UIPageControl *_page;再_page =page;
4.加上方法
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
_page.currentPage=scrollView.contentOffset.x/scrollView.frame.size.width;
}