-(id)initWithFrame:(CGRect)frame{self=[superinitWithFrame:frame];if(self){//Initializationcode_statisScrollView=[[UIScrollViewalloc]initWithFrame:CGRectMake(7,9,frame.size.width-23,frame.size.height-45)];_statisScrollView.contentSize=CGSizeMake(_statisScrollView.frame.size.width*2,_statisScrollView.frame.size.height);_statisScrollView.backgroundColor=[UIColorclearColor];_statisScrollView.pagingEnabled=YES;_statisScrollView.showsHorizontalScrollIndicator=NO;_statisScrollView.delegate=self;[selfaddSubview:_statisScrollView];[_statisScrollViewrelease];_pageControl=[[UIPageControlalloc]initWithFrame:CGRectMake(0,frame.size.height-40,frame.size.width,20)];_pageControl.backgroundColor=[UIColorclearColor];_pageControl.currentPage=0;_pageControl.numberOfPages=2;[_pageControladdTarget:selfaction:@selector(getChangePage:)forControlEvents:UIControlEventValueChanged];[selfaddSubview:_pageControl];[_pageControlrelease];}returnself;}-(void)getChangePage:(UIPageControl*)pageControl{intpage=pageControl.currentPage;CGRectframe=_statisScrollView.frame;frame.origin.x=frame.size.width*page;//根据页数计算要显示的坐标区域frame.origin.y=0;[_statisScrollViewscrollRectToVisible:frameanimated:YES];//显示}#pragmamarkUIScrollViewDelagete-(void)scrollViewDidScroll:(UIScrollView*)scrollView{CGFloatpageWidth=scrollView.frame.size.width;intpage=floor((scrollView.contentOffset.x-pageWidth/2)/pageWidth)+1;//根据坐标区域的位置计算当前第几页_pageControl.currentPage=page;//页数赋值给pageControl的当前页}