【发布时间】:2016-09-24 20:57:06
【问题描述】:
我的导航栏设置为在滚动时隐藏,但它也会在滚动时使用我的状态栏的背景颜色,在我滚动时在我的内容顶部留下白色的状态栏文本。我希望它看起来类似于许多应用程序的方式,如果我的导航栏和状态栏有橙色背景和白色文本,当滚动发生并且导航栏隐藏时,状态栏保留橙色背景。
更新1:
尝试在视图中添加一个 20 的子视图,但它没有显示出来。我可能会遗漏一些东西,因为这是我第一次尝试在没有 IB 的情况下创建应用程序。
我把这段代码放到了我的 TableViewController 中。我试过tableview。,查看。和超级视图。而且它们似乎都不起作用。
let statusBarBG = UIView()
statusBarBG.backgroundColor = UIColor.rgb(248, green: 148, blue: 6)
super.view?.addSubview(statusBarBG)
super.view?.addContstraintsWithFormat("V:|[v0(20)]", views: statusBarBG)
super.view?.addContstraintsWithFormat("H:|[v0]|", views: statusBarBG)
更新 2:
所以在尝试了一些事情之后,我的视图出现了,但它在导航栏下方并随着 tableview 滚动,这导致它在用户滚动时消失。
FeedTVController:UITableViewController
let statusBarBG = UIView(frame: CGRect(x: 0.0, y: -44, width: UIScreen.mainScreen().bounds.width, height: 20))
statusBarBG.backgroundColor = .redColor() //UIColor.rgb(248, green: 148, blue: 6)
self.view?.addSubview(statusBarBG)
应用代理:
let feedController = FeedTVController()
let navigationController = UINavigationController(rootViewController: feedController)
let tabBarController = TabBarController()
tabBarController.setViewControllers([vc1, vc2, vc3], animated: true)
window?.rootViewController = tabBarController
【问题讨论】:
-
你不能在视图顶部放置一个 20 点高且颜色正确的 UIView 吗?
标签: ios swift uinavigationbar statusbar