转自:http://blog.sina.com.cn/s/blog_8764c3140100wtoc.htmlhtml 1. @property(nonatomic) BOOL bounces //当滚动到内容边缘是否发生反弹,default is YES. 2. @property(nonatomic) BOOL alwaysBounceHorizontal; //是否只在水平发生反弹,当内容到达 边缘。。default is NO, 若是要只在水平反弹那么bounces必须为YES. 3. @property(nonatomic) BOOL alwaysBounceVertical //当滚动到达边缘时,是否只有垂直边缘才发生 反弹。default is no. 4. @property(nonatomic) BOOL bouncesZoom; //当在缩放时,到达图片最大缩放倍数(maximumZoomScale) 或者是最小缩放倍数( minimumZoomScale)时,为了告诉用户缩放倍数已达极限,是否发生动态反弹的效果来 告诉用户。defaults is YES. 5. @property(nonatomic) BOOL canCancelContentTouches; //当手指触摸屏幕后,并无开始拖动,而隔一段时间后 再开始拖动,这个属性决定是否scorllView里的图片是否会再继续随着手指的滑动,而图片跟着滑动。defualt is NO,图片会跟着手指滑动而滑动。 6. @property(nonatomic) CGPoint contentOffset; //scrollView里的内容(如里面存的图片)的原点,距离scrollView的 frame属性里的原点(origin)的距离。按照通常思惟来讲,如scrollView的frame为(0,0,320,480),而scrollView里的 图片坐标为:(-320,0,320*2,480);那么contentOffset应该为(-320,0),但其实是(320,0),多是为了方便设置,取为 正吧,反正contentOffset的x,y是不可能为负的,那样表明滚动已到边缘,发生反弹或者不能再往边缘外拖动。 7. @property(nonatomic) CGSize contentSize; //scrollView里能存储图片最大size。好比scrollView为屏幕 大小,而要在里面存放几张屏幕大小的图片,那么必定不能忘了在放图片以前设置contentSize. 8. @property(nonatomic, assign) id<UIScrollViewDelegate> delegate; //scrollView的代理。如: 当要实现缩放图片时,必须实现UIScrollViewDelegate里的两个方法,且最大、最小缩放倍数必须不同maximumZoomScale ,minimumZoomScale: - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; //返回要缩放的图片(必须在代理类里实现) - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale; //从新肯定缩放完后的缩放倍数. 经常使用来缩放方法:- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated,把从scrollView里截取的矩形 区域缩放到整个scrollView当前可视的frame里面。因此若是截取的区域大于scrollView的frame时,图片缩小, 若是截取区域小于frame,会看到图片放大。通常状况下rect须要本身计算出来。 好比,要把scrollView原来坐标点为(40,40)的内容周围内容在scrollView里放大一倍,能够求出须要从scrollView里 截取图片的frame,固然主要是求截取图片坐标原点,能够想象,内容放大一倍,那么截取图片的大小宽度确定是 scrollView的frame大小一半。以下列方法: - (CGRect) getRectWithScale:(float)scale andCenter:(float)center { CGRect newRect; newRect.size.width=scrollView.frame.size.width/scale; newRect.size.height=scrollView.frame.size.height.scale; newRect.origin.x=center.x-newRect.size.width/2; newRect.origin.y=center.y-newRect.size.height/2; return newRect; }ios 1. @property(nonatomic, getter=isDirectionalLockEnabled) BOOL directionalLockEnabled; //滚动方向的锁定。 若是一开始拖动方向是水平或者垂直,且该属性设置为YES,那么另一个方向将会被锁定,不能在那个方向拖动了。若是 开始拖动方向为斜的,那么不会禁止任何一个方向的拖动。 2. @property(nonatomic) UIScrollViewIndicatorStyle indicatorStyle; //拖动图片时,下面或者右侧的那个滚动进度条 显示的风格,固然也能够把这个滚动条取消。能够用下面属性: @property(nonatomic) BOOL showsHorizontalScrollIndicator; //是否显示水平滚动条 @property(nonatomic) BOOL showsVerticalScrollIndicator; //是否显示垂直滚动条,default is YES 3. @property(nonatomic) float maximumZoomScale; //最大缩放倍数 @property(nonatomic) float minimumZoomScale; //最大缩小倍数 一般状况下,最小倍数比scrollView的frame要小,而最大缩放倍数可能与contentSize有关,须要本身算出 最大缩放倍数,如:若是想最大缩放倍数为5倍,那么contentSize也应该设置为5倍scrollView的frame大小。 假如想要双击scrollView里的图片放大,或者支持两只手指在屏幕捏放实现图片缩放,必须重写覆盖继承自 UIResponder的几个交互方法: ﹣(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; ﹣(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; ﹣(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; , getter=isPagingEnabled) BOOL pagingEnabled; //是否在拖动图片后,图片翻到 scrollView的下一个子视图开始边界. default is NO @property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; //是否能够滚动。default is YES, 若是设置为NO,那么将scrollView将不会接受任何触摸事件。 - (void)setZoomScale:(float)scale animated:(BOOL)animated; 转自:君哥哥爱漂移的空间算法 |