How to extend bottom view colour below the home indicator in iPhone X?

前端 未结 3 491
生来不讨喜
生来不讨喜 2020-12-24 08:41

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 se

3条回答
  •  隐瞒了意图╮
    2020-12-24 09:01

    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. :)

提交回复
热议问题