#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];
? ? ? ? ? ? //初始化滾動(dòng)視圖
? ? ? ?theSceo = [[UIScrollView alloc]initWithFrame:self.view.frame];
? ? ? ? //設(shè)置代理
? ? ?theSceo.delegate = self;
? ? ? //設(shè)置按頁滾動(dòng)
? ? theSceo.pagingEnabled = YES;
? ? //設(shè)置是否顯示滾動(dòng)條
? ? theSceo.showsHorizontalScrollIndicator = NO;
? ? //添加到視圖
[self.view addSubview:theSceo];
theArr = @[@"1.jpeg",@"2.jpeg",@"3.jpeg",@"4.jpeg"];
CGFloat x = 0.0

//初始化一個(gè)分頁控制器
thePage = [[UIPageControl alloc]initWithFrame:CGRectMake((self.view.frame.size.width)/2-30, self.view.frame.size.height/5*4, 60, 20)];
//設(shè)置分頁控制器個(gè)數(shù)
thePage.numberOfPages = theArr.count;
//設(shè)置分頁控制器的 顏色
thePage.pageIndicatorTintColor = [UIColor whiteColor];
//社會(huì)化做分頁控制器選中的顏色
thePage.currentPageIndicatorTintColor = [UIColor redColor];
//添加到視圖
[self.view addSubview:thePage];
}
//實(shí)現(xiàn)分頁控制器與滾動(dòng)視圖的關(guān)聯(lián)
- (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