IOS开发-UI学习-UIPageControl(页码控制器)的使用

UIPageControl即页码控制器,是在翻动图片阅览时下面显示的几个小点,属性设置如下;

 1     UIPageControl *pagecontrol = [[UIPageControl alloc]initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 50)];
 2 //    设置背景色
 3     pagecontrol.backgroundColor = [UIColor grayColor];
 4 //    设置当前页
 5     pagecontrol.currentPage = 0;
 6 //    设置总页数
 7     pagecontrol.numberOfPages = 100;
 8 //    设置当前页的小点显示的颜色
 9     pagecontrol.currentPageIndicatorTintColor = [UIColor redColor];
10 //    设置其他非当前页小点的颜色
11     pagecontrol.pageIndicatorTintColor = [UIColor blueColor];
12 //    添加事件
13     [pagecontrol addTarget:self action:@selector(haha:) forControlEvents:UIControlEventTouchUpInside];
14     
15 //    添加到当前view
16     [self.view addSubview:pagecontrol];

也可以给他添加事件如下:

1 -(void)haha:(id)sender{
2     ;
3 }
原文地址:https://www.cnblogs.com/jiwangbujiu/p/5360245.html