#import "ViewController.h"
#import "oneViewController.h"
@interface ViewController (){
UIScrollView *theSceo;
NSArray *theArr;
UIPageControl *thePage;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
//初始化滚动视图
theSceo = [[UIScrollView alloc]initWithFrame:self.view.frame];
//设置代理
theSceo.delegate = self;
//设置按页滚动
theSceo.pagingEnabled = YES;
//设置是否显示滚动条
theSceo.showsHorizontalScrollIndicator = NO;
//添加到视图
[self.view addSubview:theSceo];
theArr = @[@"1.jpeg",@"2.jpeg",@"3.jpeg",@"4.jpeg"];
CGFloat x = 0.0
//初始化一个分页控制器
thePage = [[UIPageControl alloc]initWithFrame:CGRectMake((self.view.frame.size.width)/2-30, self.view.frame.size.height/5*4, 60, 20)];
//设置分页控制器个数
thePage.numberOfPages = theArr.count;
//设置分页控制器的 颜色
thePage.pageIndicatorTintColor = [UIColor whiteColor];
//社会化做分页控制器选中的颜色
thePage.currentPageIndicatorTintColor = [UIColor redColor];
//添加到视图
[self.view addSubview:thePage];
}
//实现分页控制器与滚动视图的关联
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
thePage.currentPage = theSceo.contentOffset.x/self.view.frame.size.width;
}
-(void)tz{
oneViewController *v1 = [oneViewController new];
[self presentViewController:v1 animated:YES completion:^{
}];
}
@end