1 CGRect screentRect = self.view.bounds;
2 CGRect bigRect = screentRect;
3 bigRect.size.width *= 2.0;
4 // bigRect.size.height *= 2.0;
5
6 //创建一个UIScrollView对象,将其尺寸设置为窗口大小
7 UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:screentRect];
8 //分栏
9 [scrollView setPagingEnabled:YES];
10 [self.view addSubview:scrollView];
11
12 //创建一个有着超大尺寸的BNRHypnosisView 对象并将其加入UIScrollView对象
13 // BNRHypnosisView *hypnosisView = [[BNRHypnosisView alloc]initWithFrame:bigRect];
14 BNRHypnosisView *hypnosisView = [[BNRHypnosisView alloc]initWithFrame:screentRect];
15 [scrollView addSubview:hypnosisView];
16
17 //创建第二个大小与屏幕相同的BNRHypnosisView对象并放置在第一个BNRHypnosisView
18 //对象的右侧,使其刚好移出屏幕外
19 screentRect.origin.x +=screentRect.size.width;
20 BNRHypnosisView *anotherView = [[BNRHypnosisView alloc]initWithFrame:screentRect];
21 [scrollView addSubview:anotherView];
22
23 //告诉UIScrollView对象"取景" 范围有多大
24 scrollView.contentSize = bigRect.size;