Getting a white space at bottom of iPhone X screen (Xcode 9)

冷暖自知 提交于 2019-11-28 15:46:54

问题


I'm using Xcode 9 for my project and I'm getting a white space at the bottom, here is the screenshot:

Also I'm using storyboard to design with 4 inches (iphone 5s/SE) as layout.

How to avoid the white space?


回答1:


Your bottom constraints should be from view not from the bottom layout guide or safe area(xcode 9 specific) and your distance should be zero.

Default it was pinned with layout guides, so give it with view !

Refer below screenshot for better understanding,

to open this dialogue, click drop down icon of field contains 0!

You can do same for top constraint also!

Update :

Second main important thing,

you should use storyboard for your launch or splashscreen. If you are using launch image then replace it by new launch image of xcode 9 and it have option for the image of iphone x.

Then you will not found white space any more!

Refer below screenshot.




回答2:


This white space is your main view. If you want your image view to fill the whole area, pin it with 0 space to the superview, not to Bottom Layout Guide or Safe Area. To achieve this, select to view scene in storyboard as iPhone X and pin the image view as below:

It is also possible to pin the bottom of image view to superview when not in iPhone X mode: when you pin by dragging with Ctrl, when the list of constaints appears press Option key (alt) and you will see "Bottom Space to Container Margin".




回答3:


Neither of the two answers above worked for me. Only setting

 scrollView.contentInsetAdjustmentBehavior = .never

I have a stackView inside my scrollView and the elements in the stackView have fixed sizes, so I have no need to inset adjustment and this works.

Credit goes to How to get rid of safeAreaInsets on UIScrollview (iOS 11, iPhoneX)




回答4:


For me this worked:

1) Select image for which you are setting up constraints

2) Go to Attribute inspector in the right panel

3) Select Scale to Fill as Content Mode



来源:https://stackoverflow.com/questions/46322150/getting-a-white-space-at-bottom-of-iphone-x-screen-xcode-9

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!