关闭

UIScrollView属性详解

标签: uiscrollview
130人阅读 评论(0) 收藏 举报
分类:
UIScrollView属性详解
 iOS学习总结

@property(nonatomic)  CGPoint contentOffset; 

// default CGPointZero

内容的偏移位置。默认为(0,0),左上角原点。

@property(nonatomic)  CGSize  contentSize;                    

// default CGSizeZero

滚动范围的大小

@property(nonatomic)  UIEdgeInsets contentInset;                   

// default UIEdgeInsetsZero. add additional scroll area around content

内容视图在scrollview中的位置,UIEdgeInsets描述一个矩形区域。

@property(nonatomic,assignid<UIScrollViewDelegate>   delegate;

// default nil. weak reference

委托

@property(nonatomic,getter=isDirectionalLockEnabled) BOOL directionalLockEnabled;         

// default NO. if YES, try to lock vertical or horizontal scrolling while dragging

指定控件是否只能在一个方向上滚动

@property(nonatomic)    BOOL  bounces;                        

// default YES. if YES, bounces past edge of content and back again

内容遇到边框是否反弹

@property(nonatomic)    BOOL  alwaysBounceVertical;           

// default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag vertically

垂直方向遇到边框是否反弹

@property(nonatomic)    BOOL alwaysBounceHorizontal;         

// default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag horizontally

水平方向遇到边框是否反弹

@property(nonatomic,getter=isPagingEnabled) BOOL pagingEnabled;                  

// default NO. if YES, stop on multiples of view bounds

是否分页

@property(nonatomic,getter=isScrollEnabled) BOOL  scrollEnabled;                  

// default YES. turn off any dragging temporarily

是否允许滚动

@property(nonatomic)     BOOL showsHorizontalScrollIndicator; 

// default YES. show indicator while we are tracking. fades out after tracking

是否显示水平方向滚动条

@property(nonatomic)     BOOL showsVerticalScrollIndicator;   

// default YES. show indicator while we are tracking. fades out after tracking

是否显示垂直方向滚动条

@property(nonatomic)   UIEdgeInsets   scrollIndicatorInsets;          

// default is UIEdgeInsetsZero. adjust indicators inside of insets

滚动条在滚动视图中的位置

@property(nonatomic)   UIScrollViewIndicatorStyle   indicatorStyle;                 

// default is UIScrollViewIndicatorStyleDefault

滚动条样式

@property(nonatomic)   float  decelerationRate NS_AVAILABLE_IOS(3_0);

滑动速率



@property(nonatomic,readonly,getter=isTracking)     BOOL tracking;        

// returns YES if user has touched. may not yet have started dragging

用户已经触屏,但还拖动,返回YES。

@property(nonatomic,readonly,getter=isDragging)     BOOL dragging;        

// returns YES if user has started scrolling. this may require some time and or distance to move to initiate dragging

拖动中,返回YES。

@property(nonatomic,readonly,getter=isDecelerating) BOOL decelerating;   

// returns YES if user isn't dragging (touch up) but scroll view is still moving

滑动中,返回YES

@property(nonatomicBOOL delaysContentTouches;       

// default is YES. if NO, we immediately call -touchesShouldBegin:withEvent:inContentView:

是否延迟调用touchesShouldBegin:withEvent:inContentView

@property(nonatomicBOOL canCancelContentTouches;    

// default is YES. if NO, then once we start tracking, we don't try to drag if the touch moves

如果为NO,我们保持触屏状态,移动手指,将不能拖动。

@property(nonatomicfloat minimumZoomScale;     

// default is 1.0

最小缩放比例

@property(nonatomicfloat maximumZoomScale;     

// default is 1.0. must be > minimum zoom scale to enable zooming

最大缩放比例

@property(nonatomicfloat zoomScale NS_AVAILABLE_IOS(3_0);            

// default is 1.0

缩放比例

@property(nonatomicBOOL  bouncesZoom;          

// default is YES. if set, user can go past min/max zoom while gesturing and the zoom will animate to the min/max value at gesture end

缩放时候是否遇边界反弹

@property(nonatomic,readonly,getter=isZooming)       BOOL zooming;       

// returns YES if user in zoom gesture

正在缩放

@property(nonatomic,readonly,getter=isZoomBouncing)  BOOL zoomBouncing;  

// returns YES if we are in the middle of zooming back to the min/max value

正在缩放反弹




// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.

// On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.

@property(nonatomicBOOL  scrollsToTop;          // default is YES.

// Use these accessors to configure the scroll view's built-in gesture recognizers.

// Do not change the gestures' delegates or override the getters for these properties.

@property(nonatomicreadonlyUIPanGestureRecognizer *panGestureRecognizer NS_AVAILABLE_IOS(5_0);

按下的手势

// `pinchGestureRecognizer` will return nil when zooming is disabled.

@property(nonatomicreadonlyUIPinchGestureRecognizer *pinchGestureRecognizer NS_AVAILABLE_IOS(5_0);

捏合手势



这里把UIScrollView的几个要点总结下:

从你的手指touch屏幕开始,scrollView开始一个timer,如果:

1.  150ms内如果你的手指没有任何动作,消息就会传给subView。

2.  150ms内手指有明显的滑动(一个swipe动作),scrollView就会滚动,消息不会传给subView,这里就是产生问题二的原因。

3. 150ms内手指没有滑动,scrollView将消息传给subView,但是之后手指开始滑动,scrollView传送touchesCancelled消息给subView,然后开始滚动。

观察下tableView的情况,你先按住一个cell,cell开始高亮,手不要放开,开始滑动,tableView开始滚动,高亮取消。

 

delaysContentTouches的作用:

这个标志默认是YES,使用上面的150ms的timer,如果设置为NO,touch事件立即传递给subView,不会有150ms的等待。

 

cancelsTouches的作用:

这个标准默认为YES,如果设置为NO,这消息一旦传递给subView,这scroll事件不会再发生。


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:13279次
    • 积分:166
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:17篇
    • 译文:0篇
    • 评论:0条
    文章分类