COL*_*ICE 5 uitabbarcontroller uinavigationcontroller uisearchbar swift
单击 SearchBar 时出现多条白线。
同时使用TabBarController和彩色条NavigationController时会发生这种情况,但是
我使用以下代码行在AppDelegate 中设置导航颜色:
UINavigationBar.appearance().barTintColor = UIColor(rgb: 0x0277BD)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
Run Code Online (Sandbox Code Playgroud)
我使用以下方法在SearchViewController 中设置了 UISearchController :
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
// Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Events"
searchController.searchBar.tintColor = .white
navigationItem.searchController = searchController
definesPresentationContext = true
}
Run Code Online (Sandbox Code Playgroud)
知道发生了什么吗?
不确定这是否是一个令人满意的答案,但它看起来像一个 iOS 错误,这可能与默认添加到顶部栏的半透明效果有关。顶部栏由两部分组成(导航和搜索),在上滑动画期间,白线似乎出现在导航部分的底部边缘。如果你添加navigationController?.navigationBar.isTranslucent = false到你的,viewDidLoad()问题就会消失。
UINavigationController为什么只有在嵌入时才会出现白线UITabBarController?不知道:(这isTranslucent = false件事充其量只是一个解决方法,但也许这就足够了。
| 归档时间: |
|
| 查看次数: |
545 次 |
| 最近记录: |