iOS hidesBarsOnSwipe 状态栏背景色 [英] iOS hidesBarsOnSwipe status bar background color

查看:59
本文介绍了iOS hidesBarsOnSwipe 状态栏背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 hidesBarsOnSwipe 属性滑动和隐藏导航栏时,状态栏具有清晰的背景.如何将状态栏的背景设置为与导航栏相同的颜色?这是一些显示我的问题的图片,这些都包含在 UITableViewController 中.

When I swipe and hide the navigation bar with the hidesBarsOnSwipe property the status bar has a clear background. How can I set the background of the status bar to the same color as the navigation bar? Here are a few pictures showing my problem, this is all contained in a UITableViewController.

分开

单独的图片,看起来像一张大的.

Separate picture, looks like one big one.

推荐答案

我遇到了同样的问题,并且能够解决它.我对 iOS 开发人员还很陌生,我不认为这个解决方案是万无一失的.我在其他地方找不到任何好的答案,所以我是如何克服它的:

I've come across the same issue, and was able to solve it. I'm fairly new to iOS dev, and I don't imagine this solution to be foolproof. I couldn't find any good answers elsewhere, so here's how I overcame it:

  1. 我从 UITableViewController 转换为带有嵌套 UITableView 的 UIViewController.请注意,仔细检查子 tableview 的委托是否设置为 UIViewController.
  2. 我添加了一个高度为 20px 的视图和一个背景颜色,你想将它设置为状态栏的背景".在该视图上设置约束如下:

  1. I converted from a UITableViewController over to UIViewController with a nested UITableView. Note, double check that the delegate to the child tableview is set to the UIViewController.
  2. I Added a view with a height of 20px and a background colour that you want to set as the "background" to the status bar. Set the constraints on that view as follows:

在您的表格视图上,将约束设置为基本上全屏.这里有一个重要的注意事项,顶部约束是Top Layout Guide.Top"而不是Top Layout Guide.Bottom".默认情况下,我相信这个约束与底部有关.双击约束允许您将其调整到顶部.没有这个,任何表格标题单元格都没有为我正确定位

On your table view, set the constrains to be basically full screen. One important note here, the top constraint is to "Top Layout Guide.Top" and not to "Top Layout Guide.Bottom". By default I believe this constraint ties to the bottom. Double clicking on the constraint allows you to adjust it to the top. Without this, any table header cells weren't positioned properly for me

希望有所帮助.

这篇关于iOS hidesBarsOnSwipe 状态栏背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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