View doesn't go under status bar and status bar is black

好久不见. 提交于 2019-12-06 01:06:54

You're not doing anything "wrong". You have set the top of the image view to the bottom of the view controller's top layout guide. Well, that's the bottom of the status bar — exactly where you see the top of the image view.

If you want the image view to underlap the status bar, its top needs to be pinned to the top of the main view, not the top layout guide.

And if you want the status bar to change text color, you need to implement preferredStatusBarStyle to return .LightContent. If this means that the result of preferredStatusBarStyle has changed, you would need to call setNeedsStatusBarAppearanceUpdate to alert the runtime to this fact.

To place the image view under the status bar, and have the image view fill the UIViewControllers view:

  • Clear all constraints for the image view
  • Add a constraint to set the image view to have the same width as the parent view
  • Add a constraint to set the image view to have the same height as the parent view
  • Pin the image view to the nearest neighbor as shown below. Add the constraints

  • The final constraints will look like the following:

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