//声明对象
@property (nonatomic,strong) UIPageControl *pagecontrol;
@property (nonatomic,strong) UIPageControl *pagecontrol;
//初始化
self.pagecontrol = [[UIPageControl alloc] init];
self.pagecontrol.backgroundColor = [UIColor greenColor];
self.pagecontrol.frame = CGRectMake(0, 0, 100, 37);
self.pagecontrol.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
//总页数
self.pagecontrol.numberOfPages = 5;
//当前显示页
self.pagecontrol.currentPage = 1;
//其他页码指示器的颜色
self.pagecontrol.pageIndicatorTintColor = [UIColor purpleColor];
//当前页码指示器的颜色
self.pagecontrol.currentPageIndicatorTintColor = [UIColor redColor];
//只有一页时,是否隐藏页码指示器
self.pagecontrol.hidesForSinglePage = YES;
[self.view addSubview:self.pagecontrol];
//添加事件
[self.pagecontrol addTarget:self action:@selector(click:) forControlEvents:UIControlEventValueChanged];
self.pagecontrol = [[UIPageControl alloc] init];
self.pagecontrol.backgroundColor = [UIColor greenColor];
self.pagecontrol.frame = CGRectMake(0, 0, 100, 37);
self.pagecontrol.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
//总页数
self.pagecontrol.numberOfPages = 5;
//当前显示页
self.pagecontrol.currentPage = 1;
//其他页码指示器的颜色
self.pagecontrol.pageIndicatorTintColor = [UIColor purpleColor];
//当前页码指示器的颜色
self.pagecontrol.currentPageIndicatorTintColor = [UIColor redColor];
//只有一页时,是否隐藏页码指示器
self.pagecontrol.hidesForSinglePage = YES;
[self.view addSubview:self.pagecontrol];
//添加事件
[self.pagecontrol addTarget:self action:@selector(click:) forControlEvents:UIControlEventValueChanged];