分享

iOS scrollView的一些小知识(持续整理中)

 南山岳麓书院 2016-08-19

工作中碰到的一些小的知识总结一下:    

   1.self.automaticallyAdjustsScrollViewInsets = NO; // 解决scrollView自动调节contentInset的问题

        The default value of this property is YES, which lets container view controllers know that they should adjust the scroll view insets of this view controller’s view to account for screen areas consumed by a status bar, search bar, navigation bar, toolbar, or tab bar. Set this property to NO if your view controller implementation manages its own scroll view inset adjustments.
       这个属性的默认值是YES的,这让容器视图控制器知道他们应该调整滚动视图insets来让视图控制器的视图被一个状态栏,搜索栏,导航栏,工具栏,或标签栏占据屏幕区域。如果你的视图控制器实现自己管理滚动视图inset,设置该属性NO。
如果你在控制器中有设置 status bar, search bar, navigation bar, toolbar, or tab bar这些控件,且self.automaticallyAdjustsScrollViewInsets = YES的话,系统会自动调整contentInset。
   2.contentSize 是scrollview中的一个属性,它代表scrollview中的可显示区域,假如有一个scrollview,它的frame为(0,0,320,480),而它的contentSize为(320,960).也就是说,这个scrollview整个内容的大小为(320,960),要通过上下滑动scrollview来查看(320,480)后的内容。
contentOffset 是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480。
contentInset 是scrollview中contentView.frame.origin与scrollview.frame.origin的关系,比如contentView的frame为(0,30,320,480),那么contentInset则为(0, 30),

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多