如何在iPhone X中扩展家庭指示器下方的底视图颜色? [英] How to extend bottom view colour below the home indicator in iPhone X?

查看:133
本文介绍了如何在iPhone X中扩展家庭指示器下方的底视图颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看附件图片。 Viewcontroller的视图背景颜色为蓝色。如您所见,此颜色延伸到状态栏下方和主页指示器下方。底部有一个白色视图,这是一个按钮。这里的白色视图位于安全布局指南中。



我希望在家庭指示器下方延伸相同的白色,而不为iPhone-X添加任何其他视图。



如何做到这一点?



解决方案

Krunal的答案适用于大多数情况。但如果您没有设置顶部约束,白色视图将位于主页指示行下。





在我的设计中,白色视图仅具有前导,尾随,底部和高度约束。我必须将另一个视图作为子视图添加到白色视图(此视图将从现在起充当白色视图),启用外部白色视图的安全区域布局指南并将约束设置为边距/安全区域以便让这个东西适用于所有设备,包括X.



注意:应该为内部视图/按钮(在我的情况下)设置高度约束,而不是为外部视图设置高度约束。 Autolayout将在iphone X设备中为您正常工作。





这就是它在iPhone和其他手机中的外观。
iPhone SE:





希望这可以帮助某人。 :)


Please check the attached image. The Viewcontroller's view's background colour is blue. This colour extends below the status bar and below the home indicator as you can see. There is a white view at the bottom which is a button. Here the white view is inside the safe layout guide.

I want the same white colour to extend below the home indicator without adding any additional view only for iPhone-X.

How to do this?

解决方案

Krunal's answer works in most cases. But if you don't have that top constraint set, the white view will go under the home indicator line.

In my design, the white view had leading ,trailing,bottom and height constraints only. I had to add another view as a subview to the white view (This view will act as the white view from now),enable the safe area layout guide for the outer white view and set the constraints to the margin/safe area in order to get this thing work for all the devices including X.

NB: Height constraint should be set for the inner view/Button(in my case) and not for the outer view. Autolayout will properly do the work for you in iphone X device.

This is how it looks in iphone X and other phones. iPhone SE:

iPhone X:

Hope this may help someone. :)

这篇关于如何在iPhone X中扩展家庭指示器下方的底视图颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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