热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何单独为iPhoneX设备设置约束-HowtosetconstraintsforiPhoneXdevicealone

Ihavealogointhestoryboardsettoatopconstraintofvalue28anditworksforalldevices.On

I have a logo in the storyboard set to a top constraint of value 28 and it works for all devices. On iPhone X device it merges with the camera bar on the top. If i increase the top constraint it affects the other devices. How do i set a constraint only for iPhone X alone?

我在故事板中有一个标识设置为值28的顶部约束,它适用于所有设备。在iPhone X设备上,它与顶部的相机条合并。如果我增加顶部约束,它会影响其他设备。如何仅为iPhone X设置约束?

1 个解决方案

#1


6  

By default Xcode provides you with a Safe Area upon project creation.

默认情况下,Xcode会在项目创建时为您提供安全区域。

enter image description here

Here, I've added a UIView with the following constraints. Take note of how the constraints are pinned to the Safe Area, and not the Superview. enter image description here

在这里,我添加了一个具有以下约束的UIView。请注意约束如何固定到安全区域,而不是超级视图。

Running the app, you'll see that the view respects the status bar across all devices.

运行该应用程序,您将看到该视图尊重所有设备的状态栏。

Hope this helps with the issue you're having...

希望这有助于解决您遇到的问题......


推荐阅读
author-avatar
小于2502919693
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有