设置状态栏颜色以匹配 UISearchBar

Set status bar color to match UISearchBar

我有一个搜索视图,它将带有 UISearchBar 的 UITableView 显示为 tableHeaderView。滚动 table,文本会重叠并显示在状态栏下方。我尝试过的所有解决方案都不起作用。我的偏好是将状态栏设为灰色,以匹配 UISearchBar,就像建议的那样 here

那个和我试过的其他东西都没有用。任何帮助将不胜感激。

以下有效:

func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
    return .TopAttached
}

但副作用是现在搜索栏和第一个 table 单元格之间存在偏移。