标签:
#import "RootViewController.h" @interface RootViewController () @end @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; /** * UIPageControl 分页控件,提供以下几个功能: 1.展示当前总页数 2.展示当前是第几页 3.切换pageControl的当前显示的点对应显示不同的界面 */ //1.创建控件 UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(20, 30, 260, 30)]; //2.配置属性 // pageControl.backgroundColor = [UIColor redColor]; //3.设置显示的总页数 pageControl.numberOfPages = 10; //4.设置点颜色 pageControl.pageIndicatorTintColor = [UIColor redColor]; //设置当前点的颜色 current 当前的意思 pageControl.currentPageIndicatorTintColor = [UIColor blueColor]; //设置默认的当前点 pageControl.currentPage = 5; //添加响应事件 [pageControl addTarget:self action:@selector(handlePageControl:) forControlEvents:UIControlEventValueChanged]; //3.添加到父视图 [self.view addSubview:pageControl]; //4.释放 [pageControl release]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma 点 - (void)handlePageControl:(UIPageControl *)pageControl { NSLog(@"%ld",pageControl.currentPage); }
标签:
原文地址:http://www.cnblogs.com/wohaoxue/p/4764669.html