我希望我的導航欄和搜索欄具有相同的顏色。我也想擺脫他們之間的細線,但與第一個相比,這似乎是一個小問題。 的導航欄屬性設置是這樣的:導航欄和搜索控制器
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 –