UIView 01 - frame, bounds, center的区别

最近发现UIView最基本的一些内容都没有理解好,因此打算阅读官方文档的同时也把自己所学习的记录下来。
https://developer.apple.com/documentation/uikit/uiview

frame,bounds,center是UIView对象的几个位置属性,下面是官方文档中对这几个属性的定义。

The geometry of each view is defined by its frame and bounds properties.The frame property defines the origin and dimensions of the view in the coordinate system of its superview.The bounds property defines the internal dimensions of the view as it sees them and is used almost exclusively in custom drawing code.The center property provides a convenient way to reposition a view without changing its frame or bounds properties directly.

frame: 描述当前视图在其父视图中的坐标位置和大小,用于确定与视图层次结构中其他视图的相对位置,从而将自己的图层与其他视图的图层正确组合成屏幕上的图像。

bounds: 描述当前视图在其自身坐标系统的位置和大小,用于确定绘制区域,避免将自己绘制到图层边界之外。

center: 描述当前视图的中心在其父视图中的位置

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容