美文网首页
ScrollView轮回滚动,pageControl

ScrollView轮回滚动,pageControl

作者: 李毅然 | 来源:发表于2016-04-11 20:55 被阅读0次

/********************************/

[self.pageControladdTarget:selfaction:@selector(didClickPageControl:)forControlEvents:(UIControlEventValueChanged)];

/*******轮回滚动********/

-(void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView{

if(scrollView.contentOffset.x==0) {

self.scrollView.contentOffset=CGPointMake(ScreenWidth*4,0);

}

if(self.scrollView.contentOffset.x==ScreenWidth*5) {

self.scrollView.contentOffset=CGPointMake(ScreenWidth,0);

}

/*****图片滚动,改变小点*****/

NSIntegerpageNumber =(long) (scrollView.contentOffset.x-1) /ScreenWidth;

self.pageControl.currentPage= pageNumber;

}

/*****改变小点,图片滚动*****/

-(void)didClickPageControl:(UIPageControl*)pageControl{

CGPointnewPoint =CGPointMake((pageControl.currentPage+1) *ScreenWidth,0);

[self.scrollViewsetContentOffset:newPointanimated:YES];

}

相关文章

网友评论

      本文标题:ScrollView轮回滚动,pageControl

      本文链接:https://www.haomeiwen.com/subject/iomilttx.html