码迷,mamicode.com
首页 > 其他好文 > 详细

浅谈UIScrollView

时间:2015-03-12 01:07:17      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:ios uiscrollview

        普通的UIView不具备滚动功能,不能显示过多的内容UIScrollView是一个能够滚动的视图控件,可以用来展示大量的内容,并且可以通过滚动查看所有的内容。

    如果UIScrollView无法滚动,可能是以下原因:

没有设置contentSize

scrollEnabled=NO

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

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


        UIScrollViewdelegate需要实现的方法都定义在了UIScrollViewDelegate协议中,因此要想成为UIScrollViewdelegate,必须遵守UIScrollViewDelegate协议,然后实现协议中相应的方法,就可以监听UIScrollView的滚动过程了。

        常见属性        

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


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


@property(nonatomic)UIEdgeInsetscontentInset; 这个属性能够在UIScrollView4周增加额外的滚动区域


@property(nonatomic)BOOLbounces;设置UIScrollView是否需要弹簧效果


@property(nonatomic,getter=isScrollEnabled)BOOLscrollEnabled; 设置UIScrollView是否能滚动


@property(nonatomic)BOOLshowsHorizontalScrollIndicator;是否显示水平滚动条


@property(nonatomic)BOOLshowsVerticalScrollIndicator;是否显示垂直滚动条


    只要将UIScrollViewpageEnabled属性设置为YESUIScrollView会被分割成多个独立页面,里面的内容就能进行分页展示一般会配合UIPageControl增强分页效果,UIPageControl常用属性如下一共有多少页

@property(nonatomic) NSIntegernumberOfPages;


当前显示的页码

@property(nonatomic) NSIntegercurrentPage;


只有一页时,是否需要隐藏页码指示器

@property(nonatomic) BOOLhidesForSinglePage;


其他页码指示器的颜色

@property(nonatomic,retain) UIColor *pageIndicatorTintColor;


当前页码指示器的颜色

@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor;


本文出自 “热爱开发热爱创造” 博客,转载请与作者联系!

浅谈UIScrollView

标签:ios uiscrollview

原文地址:http://ioscto.blog.51cto.com/9952907/1619516

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!