1.contentSize幕布实际大小决定滚动的方向,如果小于图片本身不滚动,默认也是不滚动
view.contentSize = CGSizeMake(1280, 200);
而frame只是用来显示UIScrollView的显示区域的大小用户看的到的。
2.页面效果,图片不可以停留在两张图中间
sview.pagingEnabled = YES;
3.是否有横向竖向滚动条,滚动条的样式黑色白色
sview.showsHorizontalScrollIndicator = NO;
sview.showsVerticalScrollIndicator = NO;
sview.indicatorStyle = UIScrollViewIndicatorStyleWhite;
4.边缘拉动弹簧效果
sview.bounces = YES;
5.设置不能滚动了
sview.scrollEnabled = NO;
6.表示滚动指示器从封闭滚动视图中被嵌入的距离
top right 作用于纵向
buttom left 作用于横向
sview.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 0);
7.内容滚动区域增加的距离
下拉刷新 上拉加载 滚动的时候始终有一段距离回不去
sview.contentInset =UIEdgeInsetsMake(0, 0, 0, 0);
8.当前显示的位置
sview.contentOffset = CGPointMake(320*2, 0);
int page = scrollView.contentOffset.x/320.0;
9.常用代理方法
滚动中-(void)scrollViewDidScroll:(UIScrollView *)scrollView{}
即将开始拖动-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{}
即将开始减速-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{}
设置可以缩放的视图-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{}
10.最大放大倍数缩小倍数
sview.minimumZoomScale = 0.5;
sview.maximumZoomScale = 2;
sview.zoomScale目前拉伸的比例
放大缩小 只能对子视图进行缩放
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
UIImageView * iview = [scrollView viewWithTag:1];
return iview;
}
11.下方的小白点,不是UIScrollView上的,而是自己添加的
self.pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, 180, 320, 20)];
self.pageControl.numberOfPages = 4;
[_pageControl addTarget:self action:@selector(pageChanged) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_pageControl];
-(void)pageChanged{
[_sview setContentOffset:CGPointMake(320*_pageControl.currentPage, 0) animated:YES];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
int page = scrollView.contentOffset.x/320.0;
[self.pageControl setCurrentPage:page];
}