美文网首页
iOS frame、bounds、center

iOS frame、bounds、center

作者: 依米米一 | 来源:发表于2020-03-26 11:13 被阅读0次

看到网上好多关于 frame和bounds的解释,有些长篇概论有些模糊不清,其本质:

frame 以父视图左上角位置为(0,0)点(参照物-父view)

center 中心点在父view坐标系统中的位置和大小(参照物-父view)

bounds 以自身的左上角为(0,0)点(参照物-本身)

直接上代码贴图

设置frame,看打印信息就都明白了

设置frame代码 设置frame后的图
设置bounds代码 设置bounds后的图

注:直接设置bounds,无论x,y怎么设置,其center点都是父view的原点(0,0)

相关文章

网友评论

      本文标题:iOS frame、bounds、center

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