我有一个ImageView,它位于视图中央的顶部。 这在所有设备上看起来都很好,除了iPhone X,那里有一个缺口裁剪了图像。 有没有一种方法可以从缺口而不是屏幕的顶部角落来定位视图?因为它正在影响我的布局一致性。 谢谢
在布局imageView时,请使用安全区域指南: NSLayoutConstraint.activate([ imageView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor), // rest of the constraints ])