标签:style io color ar os sp for div on
sd
是iOS中的滑动控件,可以来解决当药显示内容个区域超过屏幕大小时,可以通过滑动操作看全内容区域,他是滑动控件的基类.UITableView.UITextView的父类
属性
设置内容区域的大小 contentSize
关闭水平指示器 showsHorizontalScrollIndicator
关闭竖直指示器
showsVerticalScrollIndicator
设置是否可以滑动
scrollEnabled
关闭反弹效果
bounces
设置偏移量
contentOffset其实是修改的scrollView的bounds的origin
x 变大往左走 y变大往上走
控制scrollView滑动是单向滑动,就是不能即向上又向又
关闭当内容区域小于scrollView时的反弹效果
水平
alwaysBounceHorizontal
竖直
alwaysBounceVertical
设置点击顶部状态条,scrollView内容是否回到顶部
scrollsToTop
有自己的专一的协议
UIScrollViewDelegate
和缩放有关的属性
minimumZoomScale 最小比例
maximumZoomScale 最大比例
协议中的方法
//scrollView 只要滑动就会触发 - (void)scrollViewDidScroll:(UIScrollView
*)scrollView { NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }// any offset changes
//只要缩放就会触发 - (void)scrollViewDidZoom:(UIScrollView
*)scrollView NS_AVAILABLE_IOS(3_2) {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//当手指触摸到scrollView,scrollView将要拖拽时触发
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//当手指当要离开scrollView,scrollView将要结束拖拽时触发
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity
targetContentOffset:(inout
CGPoint *)targetContentOffset
NS_AVAILABLE_IOS(5_0) {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//当手指离开scrollView,scrollView结束拖拽时触发
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{ NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//此时手指已经离开scrollView
//当scrollView将要开始减速时触发(减速的前提是必须要加速)
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }// called on finger up as we are moving
//当scrollView结束减速时触发
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// [scrollView setContentOffset:CGPointMake(320, 400) animated:YES];
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }// called when scroll view grinds to a halt
//当对scrollView修改时并且带有动画效果时触发
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{ NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//设置scrollView缩放的视图必须是scrollView的子视图
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__);
//指定缩放视图
return [self.view
viewWithTag:100]; }
//将要开始缩放时触发 - (void)scrollViewWillBeginZooming:(UIScrollView
*)scrollView withView:(UIView *)view
NS_AVAILABLE_IOS(3_2) {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//当scrollView结束缩放时
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView
*)view atScale:(CGFloat)scale {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
//当询问点击状态下scrollView是否能回到顶部时触发.
//如果属性scrollTop:设置为yes.然后进一步询问代理方法
//如果属性scrollToTop设置为no,无需进一步询问代理方法
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__);
return
NO; }// return a yes if you want to scroll to the top. if not defined, assumes YES
//当scrollView点击状态条回到顶部时触发
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
NSLog(@"%s, %d",
__FUNCTION__, __LINE__); }
标签:style io color ar os sp for div on
原文地址:http://blog.csdn.net/snn5love11314/article/details/40976175