我希望我的导航栏和搜索栏具有相同的颜色。我也想摆脱他们之间的细线,但与第一个相比,这似乎是一个小问题。 的导航栏属性设置是这样的:导航栏和搜索控制器
self.navigationController?.navigationBar.barTintColor = ColorHelper.sharedInstance.LightPink()
if let navBarFont = UIFont(name: "HelveticaNeue-Light", size: 25.0) {
let navBarAttributesDictionary: [String: AnyObject]? = [
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSFontAttributeName: navBarFont
]
self.navigationController?.navigationBar.titleTextAttributes = navBarAttributesDictionary
}
搜索栏属性:
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
searchController.searchBar.placeholder = "Search for new friends"
tableView.tableHeaderView = searchController.searchBar
searchController.searchBar.backgroundColor = ColorHelper.sharedInstance.LightPink()
searchController.searchBar.barTintColor = ColorHelper.sharedInstance.LightPink()
searchController.searchBar.backgroundImage = UIImage()
这似乎为我ColorHelper
返回不同的值LightPink
但doesn't。我检查了HEX值的颜色,它是不正确地显示颜色的导航栏,比实际情况要轻一点。任何想法为什么?改变.barStyle
没有改变任何东西。
我已经更新了我的回答如下,有两个你的问题的答案s –