_scrollViewing=[[[UIScrollView alloc]initWithFrame:CGRectMake(0 , 0, width(_specialView), height(_specialView))] autorelease];
_scrollViewing.backgroundColor=[UIColor grayColor];
_scrollViewing.pagingEnabled=YES;
_scrollViewing.contentSize=CGSizeMake(_scrollViewing.frame.size.width * 3, _scrollViewing.frame.size.height);
_scrollViewing.showsVerticalScrollIndicator=NO;
_scrollViewing.showsHorizontalScrollIndicator=NO;
_scrollViewing.delegate=self;
_scrollViewing.userInteractionEnabled = YES;//
_scrollViewing.tag = kDailyScrollViewTag;//
_scrollViewing.pagingEnabled = YES;//
_pageControl=[[[UIPageControl alloc]initWithFrame:CGRectMake(260 , 140 , 60 ,10)] autorelease];
_pageControl.currentPageIndicatorTintColor =
[UIColor whiteColor];
_pageControl.numberOfPages=3;
_pageControl.currentPage = 0;
[_pageControl addTarget:self action:@selector(pageControlValueChanged:) forControlEvents:UIControlEventTouchUpInside];
-
(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//PageControl的小点点随ScrollView滑动而变动
CGFloat pagewidth
= _scrollViewing.frame.size.width;
int page
= floor((_scrollViewing.contentOffset.x -
pagewidth/(3+2))/pagewidth)+1;
_pageControl.currentPage =
page;
}
//分页控制器方法
-(void)pageControlValueChanged:(UIPageControl *)pageControl
{
int currentPage=(int)pageControl.currentPage;
_scrollViewing=(UIScrollView *)[self.view viewWithTag:kDailyScrollViewTag];
if (currentPage>0)
{
[_scrollViewing setContentOffset:CGPointMake(currentPage*kIPhoneWidth, 0) animated:YES];
}
else
{
[_scrollViewing setContentOffset:CGPointMake(0, 0) animated:YES];
}
PageControl的小点点随ScrollView滑动而变动代码,布布扣,bubuko.com
PageControl的小点点随ScrollView滑动而变动代码
原文:http://www.cnblogs.com/tanwen1989/p/3600190.html