iOS开发iOS学习笔记将来跳槽用

ios开发UI篇--UIScrollView

2018-02-09  本文已影响32人  coder小鹏

概述

属性和方法

初始化方法

 UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];

设置偏移量

scrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width * 5, [UIScreen mainScreen].bounds.size.height);

设置视图是否支持滑动到最顶端

scrollView.scrollsToTop = YES;

设置是否反弹

 scrollView.bounces = NO;

设置是否分页

 scrollView.pagingEnabled = YES;

设置是否可以滚动

scrollView.scrollEnabled = NO;

设置是否显示滚动条

scrollView.showsHorizontalScrollIndicator = NO;

设置滚动条的样式

scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;

设置内容的边缘和Indicators边缘

scrollView.contentInset = UIEdgeInsetsMake(0, 50, 50, 0);
scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 50, 0, 0);

提示用户,Indicators flash

[scrollView flashScrollIndicators];

是否同时运动,lock

scrollView.directionalLockEnabled = YES;

代理方法

当视图开始滚动时执行此代理方法

-(void)scrollViewDidScroll:(UIScrollView *)scrollView

当视图即将开始被拖拽时执行的代理方法

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 

当视图结束拖拽时执行的代理方法

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

当视图减速停止时执行的代理方法

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

当视图开始减速时执行的代理方法

-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

是否支持滑动到顶部

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView 

视图已经放大或缩小

- (void)scrollViewDidZoom:(UIScrollView *)scrollView

缩放结束时执行的代理方法

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale

视图开始放大或者缩小时执行的代理方法

- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:
(UIView *)view

返回一个放大或者缩小的视图

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
上一篇 下一篇

猜你喜欢

热点阅读