UITableview与iPhone X上的主页指示器合并 [英] UITableview merging with the home indicator on iPhone X

查看:161
本文介绍了UITableview与iPhone X上的主页指示器合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以编程方式创建的UITableView.此UITableView与iPhone X设备上的主页指示器合并.

I have a UITableView created programmatically. This UITableView merges with the home indicator on an iPhone X device.

如何解决此问题?

推荐答案

以编程方式,将表视图的底部锚点设置为SafeAreaLayout的底部锚点.

Programatically, set bottom anchor of tableview with bottom anchor of SafeAreaLayout.

这是示例/测试代码,如何以编程方式针对界面元素设置安全区域布局.

Here is sample/test code, how to programatically set safe area layout with respect to interface elements.

if #available(iOS 11, *) {
  let guide = view.safeAreaLayoutGuide
  NSLayoutConstraint.activate([
   table.topAnchor.constraintEqualToSystemSpacingBelow(guide.topAnchor, multiplier: 1.0),
   guide.bottomAnchor.constraintEqualToSystemSpacingBelow(table.bottomAnchor, multiplier: 1.0)
   ])

} else {
   let standardSpacing: CGFloat = 8.0
   NSLayoutConstraint.activate([
   table.topAnchor.constraint(equalTo: topLayoutGuide.bottomAnchor, constant: 0),
   bottomLayoutGuide.topAnchor.constraint(equalTo: table.bottomAnchor, constant: 0)
   ])
}

以下是有用的参考(答案):

Here are useful references (answers):

  • Use Safe Area Layout programmatically
  • Safe Area of Xcode 9

这篇关于UITableview与iPhone X上的主页指示器合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆