首页 > 代码库 > UIPageControl

UIPageControl

 //UIPageControl
    //1.表示页数
    //2.表示当前处于第几页
    //3.点击切换页数
    
    stop = 0;
    [self setupFirstLanchView];
    
    //存储用户的偏好设置,存储在本地, 比如程序是否是第一次加载
    NSUserDefaults * userDefults = [NSUserDefaults standardUserDefaults];
    
//    if (![userDefults boolForKey:@"aa"]) {
//        [self setupFirstLanchView];
//        [userDefults setBool:YES forKey:@"aa"];
//        [userDefults synchronize]; // 立即同步. .
//    }
//创建程序第一次加载要显示的视图
- (void)setupFirstLanchView
{
    [self setupScrollView];
    [self setupPageControl];
}



- (void)setupPageControl
{
    UIPageControl * pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(10, [[UIScreen mainScreen] bounds].size.height - 40, 300, 20)];
    pageControl.backgroundColor = [UIColor whiteColor];
    
    pageControl.tag = 100;
    //设置表示的页数
    pageControl.numberOfPages = 6;
    
    //设置当前选中的点
    pageControl.currentPage = 0;
    
    //设置未选中点的颜色
    pageControl.pageIndicatorTintColor = [UIColor greenColor];
    //设置选中点的颜色
    pageControl.currentPageIndicatorTintColor = [UIColor redColor];
    
    //添加响应时间
    [pageControl addTarget:self action:@selector(pageControl:) forControlEvents:UIControlEventTouchUpInside];
    [pageControl addTarget:self action:@selector(pageControlValue) forControlEvents:UIControlEventValueChanged];
    
    [self.view addSubview:pageControl];
    [pageControl release];

}

UIPageControl