UIViewController的topLayoutGuide,并bottomLayoutGuide在iOS的11已被弃用应该用什么替代?
Jam*_*ang 13
以前在你的UIViewController:
customView.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor).isActive = true
customView.bottomAnchor.constraint(equalTo: bottomLayoutGuide.topAnchor).isActive = true
Run Code Online (Sandbox Code Playgroud)
现在你应该使用:
customView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
customView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true
Run Code Online (Sandbox Code Playgroud)
请注意从更改bottomAnchor到topAnchor.这是因为顶部布局指南是视图控制器顶部的矩形,因此为了将内容限制在顶部,您需要指南的底部锚点.新的保险箱布局指南是视图的矩形部分,不受条形和其他内容的影响,因此您需要顶部锚点.反之亦然,底部布局指南.
| 归档时间: |
|
| 查看次数: |
2936 次 |
| 最近记录: |