简体   繁体   English

更改UISearchController的UINavigationBar背景颜色

[英]Change UINavigationBar Background Color of UISearchController

At the minute, my search controllers "navigation bar" background is the standard default translucent however, all the other bars in my app are black translucent. 此刻,我的搜索控制器“导航栏”背景是标准的默认半透明背景,但是,我应用中的所有其他栏都是黑色半透明的。 When I print the navigationController property of the searchController, it returns nil and so does the navigationBar, but not the navigationItem. 当我打印searchController的navigationController属性时,它返回nil,而不是navigationBar,而不是navigationItem。 There are no other public properties that seem to let you change the color of the bar. 没有其他公共属性似乎可以让您更改条形的颜色。 I don't mind overriding private ivars as I wont be releasing this app on the app store. 我不介意覆盖私有ivars,因为我不会在应用商店中发布此应用。

您可以使用barTintColor属性,在Swift中将是:

searchBar.barTintColor = UIColor.redColor()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM