UIPageControl
页码控制器
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//创建一个UIPageControl(页码控制器)
UIPageControl *myPageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 50)];
//UIPageControl的底色
myPageControl.backgroundColor = [UIColor redColor];
//设置起始页
myPageControl.currentPage = 0;
//设置总页数
myPageControl.numberOfPages = 6;
//当前选中页面小圆点的颜色
myPageControl.currentPageIndicatorTintColor = [UIColor blueColor];
//没被选中页面(其余页面)小圆点的颜色,可以是一张图片
// myPageControl.pageIndicatorTintColor = [UIColor blackColor];
myPageControl.pageIndicatorTintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"666"]];
//点击UIPageControl可以添加一个方法
[myPageControl addTarget:self action:@selector(haha:) forControlEvents:UIControlEventTouchUpInside];
//将UIPageControl添加到手机界面上
[self.view addSubview:myPageControl];
}
-(void)haha:(id)a{
NSLog(@"我被点击了");
}