【发布时间】:2019-05-22 06:06:31
【问题描述】:
您好,我已经使用
设置了搜索控制器private func setupSearchbar() {
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Contacts"
self.navigationItem.searchController = searchController
self.definesPresentationContext = true
}
在我添加此代码之前一切正常
UINavigationBar.appearance().isOpaque = true
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = UIColor(named: "PrimaryDark")
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.font:Constants.AppTheme.Fonts.font(type: .FONT_BOLD, size: 22) ,NSAttributedString.Key.foregroundColor:UIColor.white]
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.font:Constants.AppTheme.Fonts.font(type: .FONT_BOLD, size: 34) ,NSAttributedString.Key.foregroundColor:UIColor.white]
现在当我点击搜索栏时,会出现大底黑条
如何解决这个问题?
查看调试
【问题讨论】:
-
这是 UITableView 标头空间。检查这个答案stackoverflow.com/questions/6380966/…
-
@BryanP 不,这不是,在我添加 UINavigationBar 代码之前这是有效的。
-
黑色是 viewController 视图默认颜色的背景色。设置您的视图控制器视图颜色。并且还要检查你的 tableview 的约束。
-
@PratikSodha View 默认颜色为白色,您的意思是 UIWindow 颜色,是的,我已经正确设置了所有约束,(上、左、下、右,0 常量,无边距)
-
@PrashantTukadiya 尝试删除 tableview 的约束并再次提供。
标签: ios swift uinavigationbar uisearchcontroller