美文网首页工作生活
frame和bounds的区别

frame和bounds的区别

作者: 我是小胡胡123 | 来源:发表于2019-07-03 10:54 被阅读0次

1,UIScrollView滚动显示原理
修改父视图的bounds的origin ,子视图的在父视图上位置改变,但是子视图的frame,bounds,center都没有改变。

这就是scrollview滑动的原理,实际上是在不断改变scrollview的bounds.origin,UIScrollView的实现就是通过bounds来实现的。contentOffset是bounds的origin。然后当bounds修改之后,会在layoutSubviews方法里面对子视图进行布局。


image.png

2,bounds不会影响自己本身的显示,但是它会影响子视图的显示偏移位置.
子视图的frame,bounds,center均不会改变,因为只是变了它的相对原点,任何视图的布局都是依赖于父视图所规定的原点做布局的

子视图的frame的origin 是相对于父视图的bounds的origin进行布局的
如果子视图frame的orgin是 30, 30, 父视图的bounds的origin是30,60, 那么子视图从视觉上就在父视图的frame的0,-30的位置显示
父 view 0,0的位置就已经是bounds.origin的位置了, 是从bounds.orign开始; 坐标原点正常是0,0,如果加上bounds.origin,此时原点对应的位置已经不是0,0,而是bounds.origin

image.png

相关文章

  • iOS纪录

    (1)View的Frame与Bounds区别 摘自 ios view的frame和bounds之区别(位置和大小)...

  • 深入探究frame和bounds的区别以及setbounds使用

    深入探究frame和bounds的区别以及setbounds使用 深入探究frame和bounds的区别以及set...

  • iOS 面试题目

    1、iOS frame和Bounds 以及frame和bounds区别2、 ios webView 加载HTML字...

  • #1 布局相关的问题集合

    1.frame 和 bounds的区别 what's the difference bewteen frame a...

  • UI基础相关

    UI基础相关: Frame 和 bounds的区别:Frame是参照父控件的 bounds是参照自己的 默认是(0...

  • frame和bounds区别

    1、frame不管对于位置还是大小,改变的都是自己本身 2、frame的位置是以父视图的坐标系为参照,从而确定当前...

  • iOS~ frame 和 bounds 的区别和联系

    推荐文章Understanding UIScrollView 1、 frame 和 bounds 的区别和联系 f...

  • bounds和frame的区别

    此情况下,在view.bounds = CGRectMake(x, y, W, H)中,无论x、y怎么设置最后打印...

  • frame 和 bounds 的区别

    frame frame是每个view必备的属性,代表的是当前视图的位置和大小,没有设置他,当前视图是看不到的。 b...

  • frame和bounds的区别

    frame: 该view在父view坐标系统中的位置和大小。(参照点是,父亲的坐标系统) bounds:该view...

网友评论

    本文标题:frame和bounds的区别

    本文链接:https://www.haomeiwen.com/subject/stxqhctx.html