self.topLayoutGuide.length returns 有时 64 有时 20

self.topLayoutGuide.length returns sometimes 64 sometimes 20

我注意到,在几次更改 UIViewController 中 UITableView 的内容插入后,self.topLayoutGuide.length 开始返回 64 而不是 20...

UITabeView 在 UIViewController 内部,在 UINavigationController 内部

需要注意的重要一点是,self.navigationController.navigationBar.frame.origin.y 始终是 20

self.topLayoutGuide.length 是 64 有什么原因吗?

self.topLayoutGuide.length是怎么计算的?

20是状态栏的高度。 44 是导航栏的高度(默认)。这就是为什么 topLayoutGuide.length = 64 (20 + 44).