【发布时间】:2014-06-29 04:19:10
【问题描述】:
我在UITableView 的顶部有一个UISearchBar,效果很好。我一直在尝试自定义其外观,当搜索栏处于活动状态时出现问题 - 它将状态栏背景颜色变为黑色。我尝试了IOS7 Status bar change to black after search is active 中的建议,但对我不起作用。
应用程序仅适用于 iOS 7。 UISearchBar 是最小搜索样式和默认栏样式,半透明和默认 barTintColor。我在我的 AppDelegate 中自定义了它的外观,如下所示:
[[UISearchBar appearance] setBarTintColor:AAColorInputBorder];
[[UISearchBar appearance] setBackgroundColor:AAColorInputBorder];
[[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil]
setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],NSForegroundColorAttributeName,
[UIFont fontWithName:@"Avenir" size:16], NSFontAttributeName,
nil] forState:UIControlStateNormal];
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setFont:[UIFont fontWithName:@"Avenir" size:14]];
有人知道如何更改状态栏背景颜色吗?我希望它与UISearchBar 的颜色相匹配。
谢谢!
【问题讨论】:
标签: ios uisearchbar uistatusbar