UIPageControl,页控件。常用语轮播图,标志当前页面以及总共有多少页的功能。
//
// ViewController.m
// UIPageControl
//
// Created by hhg on 15/9/29.
// Copyright (c) 2015年 hhg. All rights reserved.
//
#import "ViewController.h"
@interface ViewController () {
UIPageControl *myPage;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
myPage = [[UIPageControl alloc]init];
myPage.frame = CGRectMake(150, 50, 150, 50);
myPage.backgroundColor = [UIColor redColor];
myPage.currentPageIndicatorTintColor = [UIColor blueColor];
myPage.pageIndicatorTintColor = [UIColor greenColor];
myPage.numberOfPages = 5;
[myPage addTarget:self action:@selector(pageClick) forControlEvents:UIControlEventTouchUpInside];
myPage.currentPage = 2;
myPage.hidesForSinglePage = YES; // 单页时隐藏
[self.view addSubview:myPage];
}
-(void)pageClick {
NSLog(@"页控件被点击");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end