Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是意识到我的应用程序不适用于 iphoneX 的设计。我有一个 UIVIew(包含文本字段和按钮),它看起来像导航栏,所以它确实支持 iPhone 8 和 8 plus。但是,iPhoneX 的顶部为空白白色。反之亦然,如果我将 Uiview 设置为导航栏,那么 iphone8 和 8plus 的文本字段和顶部布局之间的差距会更大。我可以知道如何设置适合所有版本的约束或其他方式添加到顶部,并且在横向模式下它也会改变。非常感谢!
截屏
如果您使用的是 Interface Builder,您可能需要更新您的约束及其设置。
if #available(iOS 11.0, *) { if UIApplication.shared.keyWindow!.safeAreaInsets.top > CGFloat(0.0) { topConstraint.constant += 24 } }
或者