Extend the View Underneath the Status Bar and Multi-tasking Bar on iPhone X Without Manually Adjusting Constraints in Code?

…衆ロ難τιáo~ 提交于 2019-12-12 05:05:05

问题


I was wondering if there's a way to extend a view to be underneath the status bar and multi-tasking bar of the iPhone X without manually adjusting constraints in code based on the device. Using the safe area, container, container margins and top/bottom layout guides doesn't seem to help because the status bar is a different height on the iPhone X vs the previous iPhones and the safe area ends at the top of the multi-tasking bar whereas it ends at the bottom of the screen for previous iPhones. On top of that, the container margins, and top & bottom layout guides are the same as the safe area so those don't seem to work either. It seems like the only way is to make IBOutlets to the layout constraints and adjust the constants in code based on the device. Is there a way to do this purely through Interface Builder?

Here's an example of what I want to accomplish

Here's how it looks on a non-X iPhone. Notice how the scrollview ends off-screen at the bottom and the pineapple gets cut off at the top.


回答1:


I figured out how to fix the issue. First turn on safe area in your storyboard, then:

  1. for normal view controllers, constrain your view to the superview (top and/or bottom). If you did it right, the constant should be 0 and the view should be flush with the absolute top and/or bottom of the view controller
  2. for table views, do step 1, then with your table view still selected, under size inspector, uncheck 'Insets To Safe Area' and set Content Insets to 'Never'


来源:https://stackoverflow.com/questions/47316274/extend-the-view-underneath-the-status-bar-and-multi-tasking-bar-on-iphone-x-with

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