UI 基础----UIScrollView 的基本属性使用以及代理的使用方法

我们先来介绍几个 UIScrollView 的基本属性ide

    •@property(nonatomic) CGPoint contentOffset;    这个属性用来表示UIScrollView滚动的位置性能

    •@property(nonatomic) CGSize contentSize;    这个属性用来表示UIScrollView内容的尺寸滚动范围(能滚多远)atom

    •@property(nonatomic) UIEdgeInsets contentInset;    这个属性可以在UIScrollView的4周增长额外的滚动区域spa

详细介绍以下如:代理


    •@property(nonatomic) BOOL bounces;    设置UIScrollView是否须要弹簧效果 对象

    •@property(nonatomic,getter=isScrollEnabled) BOOL scrollEnabled;    设置UIScrollView是否能滚动 事件

    •@property(nonatomic) BOOL showsHorizontalScrollIndicator;     是否显示水平滚动条ci

    •@property(nonatomic) BOOL showsVerticalScrollIndicator;     是否显示垂直滚动条get


注意点: 若是 UIScrollView 没法滚动多是以下缘由致使的:博客

  1. 没有设置 contentSize

  2. scrollEnable =NO

  3. 没有接收到触摸事件 userInteractionEnabled = NO

  4. 没有取消autolayout功能(要想scrollView滚动,必须取消autolayout)


缩放实现的步骤:

    1.设置UIScrollView的id<UISCrollViewDelegate> delegate代理对象 

    2.设置minimumZoomScale :缩小的最小比例 

    3.设置maximumZoomScale :放大的最大比例 

    4.让代理对象实现下面的方法,返回须要缩放的视图控件

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;


分页:

只要将UIScrollView的pageEnabled属性设置为YES,UIScrollView会被分割成多个独立页面,里面的内容就能进行分页展现,通常会配合UIPageControl加强分页效果,UIPageControl经常使用属性以下  

@property(nonatomic) NSInteger numberOfPages;    一共有多少页

@property(nonatomic) NSInteger currentPage;    当前显示的页码

@property(nonatomic) BOOL hidesForSinglePage;    只有一页时,是否须要隐藏页码指示器

@property(nonatomic,retain) UIColor *pageIndicatorTintColor;    其余页码指示器的颜色

@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor;    当前页码指示器的颜色


定时器:

经过invalidate方法能够中止定时器的工做,一旦定时器被中止了,就不能再次执行任务。只能再建立一个新的定时器才能执行新的任务


著做权声明:本文为做者原创,欢迎转载分享。请尊重做者劳动,转载时保留该声明和做者博客连接,谢谢!

相关文章
相关标签/搜索