[self.imageArray objectAtIndex:self.currentPage+1];
77 }
78
79 self.firstimage.frame=CGRectMake(0, 0, WIDTH, HEIGHT);
80 self.secondimage.frame=CGRectMake(WIDTH, 0, WIDTH, HEIGHT);
81 self.thirimage.frame=CGRectMake(WIDTH*2, 0, WIDTH, HEIGHT);
82
83 [self.myScrollView addSubview:self.firstimage];
84 [self.myScrollView addSubview:self.secondimage];
85 [self.myScrollView addSubview:self.thirimage];
86
87 self.myScrollView.contentOffset=CGPointMake(WIDTH, 0);
88 }
89
90 #pragma mark scrollView Delegate
91 //在滚动结束状态转换
92 -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
93 {
94 float x=self.myScrollView.contentOffset.x;
95
96 // 向左
97 if (x<0||x==0) {
98 if (self.currentPage==0) {
99 self.currentPage=(int)self.imageArray.count-1;
100 }else{
101 self.currentPage--;
102 }
103 }
104
105 // 向右
106 if (x>2*WIDTH||x==2*WIDTH) {
107 if (self.currentPage==(int)self.imageArray.count-1) {
108 self.currentPage=0;
109 }else{
110 self.currentPage++;
111 }
112 }
113
114 self.myPageControl.currentPage=self.currentPage;
115 [self reloadImage];
116 }
View Code
|