objective-c - 如何在 iOS7 中更改 UISearchBar 的背景颜色

标签 objective-c ios7 uisearchbar background-color uisearchdisplaycontroller

iOS7中如何改变UISearchBar的背景颜色?

enter image description here

不是灰色,我想像我的 uinavigationbar 一样改变颜色

如果我使用此代码,那就是结果

searchBar.backgroundColor = [UIColor redColor];

enter image description here

那不是红色!!! 这与导航栏的背景颜色完全相同。

最佳答案

需要使用:

searchBar.barTintColor = [UIColor redColor];

enter image description here

谢谢!

关于objective-c - 如何在 iOS7 中更改 UISearchBar 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19301091/

相关文章:

ios - 为什么是: "Attempting to load .. while deallocating... :UISearchController:"

ios - 我将 NSString 放入 NSUUID 中,但我记录了错误的 UUID iOS

ios - 一种清空 UITableViewCell 上的 UIImageView 的方法

UISearchBar 占位符文本对齐的 iOS 7 问题

ios - insertRowsAtIndexPaths : crashes on first load

iphone - UISearchDisplayController - 单击覆盖,调用方法?

ios - 以编程方式为 iOS 的核心数据属性(列)设置默认值

ios - 当专辑信息可用时,按专辑对歌曲数组进行排序

ios - 导入 LocalAuthentification.framework 在 iOS 7.1 上崩溃

ios - Xamarin iOS 从搜索栏中隐藏取消按钮