self.view是否有约束?

问题描述 投票:0回答:1

self.view在ViewController上。有什么限制吗?我发现它具有顶部和左侧约束。它肯定有一个框架。自动布局系统从self.view开始。我的意思是,直到self.view为止,iOS系统仍使用框架来定位视图。之后,我们的视图可以使用自动布局添加。所以在viewcontroller中,我使用self.frame.size.width作为我自己的视图的宽度约束是正确的方法吗?我说的对吗?

ios autolayout constraints frame
1个回答
0
投票

使用screenWidth,很容易获得设备的大小并正确管理自己的视图:

let screenRect = UIScreen.main.bounds
let screenWidth = screenRect.size.width
let screenHeight = screenRect.size.height
© www.soinside.com 2019 - 2024. All rights reserved.