答案 0 :(得分:0)
如果你想在UISearchBar
的背景中设置黑色,那就试试吧..
UISearchBar *searchbar=[[UISearchBar alloc]init];
searchbar.barTintColor = [UIColor blackColor];
答案 1 :(得分:0)
UISearchBar
具有translucent
属性,请确保将其设置为false。
如果没有更多信息,我最好猜测为什么会发生这种情况:你的色调是黑色的,但它是半透明的,当它没有被选中时它会显示为黑色,因为下面没有视图,但是当它被选中时,它是白色的视图在它后面移动,导致黑色半透明看起来是灰色的。
答案 2 :(得分:0)
试试这个,
[[UISearchBar appearance] setBackgroundColor:[UIColor blackColor]];
[[UISearchBar appearance] setBarTintColor:[UIColor blackColor]];