标签:
//contentSize、contentInset和contentOffset 是 scrollView三个基本的属性。 // 滚动 self.ScrollView.contentSize =self.imageview.frame.size; //偏移X =0 Y =-74 向下偏移 self.ScrollView.contentOffset =CGPointMake(0,-74); // 边距 距离顶部74 左 0 下40 右0 self.ScrollView.contentInset = UIEdgeInsetsMake(74, 0, 40, 0); //不显示水平滚动条 self.ScrollView.showsHorizontalScrollIndicator =NO; //不显示垂直滚动条 self.ScrollView.showsVerticalScrollIndicator =NO; //控制器 实现 UIScrollViewDelegate 代理 @interface ViewController () <UIScrollViewDelegate> //只要滚动了就会触发 - (void)scrollViewDidScroll:(UIScrollView *)scrollView; { // NSLog(@" scrollViewDidScroll"); NSLog(@"ContentOffset x is %f,yis %f",scrollView.contentOffset.x,scrollView.contentOffset.y); } //开始拖拽视图 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView; { NSLog(@"scrollViewWillBeginDragging"); } //完成拖拽 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; { NSLog(@"scrollViewDidEndDragging"); } //将开始降速时 - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView; { NSLog(@"scrollViewWillBeginDecelerating"); } //减速停止了时执行,手触摸时执行执行 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView; { NSLog(@"scrollViewDidEndDecelerating"); } //滚动动画停止时执行,代码改变时出发,也就是setContentOffset改变时 - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; { NSLog(@"scrollViewDidEndScrollingAnimation"); } //设置放大缩小的视图,要是uiscrollview的subview - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; { //返回要缩放的子控件,每次只能缩放一个子控件 return imageView; } //完成放大缩小时调用 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale; { NSLog(@"完成放大缩小时调用"); } //如果你不是完全滚动到滚轴视图的顶部,你可以轻点状态栏,那个可视的滚轴视图会一直滚动到顶部,那是默认行为,你可以通过该方法返回NO来关闭它 - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView; { NSLog(@"scrollViewShouldScrollToTop"); return YES; } - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView; { NSLog(@"scrollViewDidScrollToTop"); } -(void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view { NSLog(@"用户开始缩放时调用!!scrollViewWillBeginZooming"); } -(void)scrollViewDidZoom:(UIScrollView *)scrollView { NSLog(@"用户正在缩放调用!scrollViewDidZoom"); }
学习笔记之-------UIScrollView 基本用法 代理使用
标签:
原文地址:http://www.cnblogs.com/zzgt/p/5126428.html