首页 > 代码库 > scrollView
scrollView
//设置内容页的大小
//scrollView 添加图片 如果想让视图滑动,内容页的大小必须比ScrollView得大小要大
scrollView.contentSize = CGSizeMake(320*8, 568*8);
//设置区域相对于frame上下左右 在哪显示.
// scrollView.contentInset = UIEdgeInsetsMake(100, 100, 0, 0);
//设置内容区的偏移量 ,修改ScrollView 修改左上角的点距离自身坐标原点的位置,修改bound 的origin .
// scrollView.contentOffset = CGPointMake(300, 0);
// [scrollView setContentOffset:CGPointMake(300, 0) animated:YES] ;
//设置scrollview能否滑动..yes 可以, no 不可以
// scrollView.scrollEnabled =YES;
scrollView.tag = 200;
//隐藏水平滑动指示器
scrollView.showsHorizontalScrollIndicator = NO;
//隐藏垂直滑动指示器
scrollView.showsVerticalScrollIndicator = NO;
//关闭滑动时的回弹效果
scrollView.bounces = NO;
//设置当点击状态条时能否滑动到最顶端
scrollView.scrollsToTop =YES;
//设置ScrollView是否可以整屏滑动 (一次滑动整个ScrollView的大小)
scrollView.pagingEnabled = YES;
//scrollview 的代理
scrollView.delegate = self;
// [scrollView setDelegate:self];
//设置最大缩放比例
scrollView.maximumZoomScale = 100;
//设置最小缩放比例
scrollView.minimumZoomScale = 0.001;
//还原ScrollView
[scroll setZoomScale:1.0 animated:YES];
//滑动时就会触发, (会触发多次)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"%s",__FUNCTION__);
}
///只要缩放就触发
- (void)scrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2)
{
NSLog(@"%s",__FUNCTION__);
}
//当将要拖拽时触发, 将要滑动时触发
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
NSLog(@"%s",__FUNCTION__);
}
//当结束拖拽时触发,手指将要离开屏幕时触发
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0)
{
NSLog(@"%s",__FUNCTION__);
}
//当结束拖拽时触发, 手指离开屏幕
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
NSLog(@"%s",__FUNCTION__);
}
//当ScrollView将要减速时触发 将要停止滑动时触发
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
NSLog(@"%s",__FUNCTION__);
}
//当ScrollView 结束减速时触发 , 停止滑动
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"%s",__FUNCTION__);
}
//当设置ScrollView 有一个动画效果时,该方法触发.
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
NSLog(@"%s",__FUNCTION__);
}
//用来设置要缩放的ScrollView上面的哪一个子视图,只能是子视图,不能是ScrollView本身
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return [scrollView viewWithTag:100];
}
//将要开始缩放时触发
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view NS_AVAILABLE_IOS(3_2)
{ NSLog(@"%s",__FUNCTION__);
}
//结束缩放时触发
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{ NSLog(@"%s",__FUNCTION__);}
//Scrollstotop 属性设置为yes时, 该方法才会触发,进一步询问点击进度条是否有效果.
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
{ NSLog(@"%s",__FUNCTION__);
return YES;
}
//当点击状态条并且ScrollView滑动到顶端时触发.
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{ NSLog(@"%s",__FUNCTION__);
}
scrollView