搜索栏取消按钮文字被截断

时间:2018-11-08 10:34:31

标签: swift uisearchbar ios11 uisearchcontroller

将UISearchBar设置为正常工作时会遇到各种问题。它应该显示在navigationBar中。使用“旧”方式设置navigationItem.titleView = searchController.searchBar。如下图所示,“取消”按钮的文本被截断了。任何想法如何解决这个问题?我试图将searchController.searchBar.sizeToFit()设置为没有运气。

fileprivate lazy var searchController: UISearchController = {
        let sc = UISearchController(searchResultsController:  nil)
        sc.delegate = self
        sc.searchBar.delegate = self
        sc.searchBar.returnKeyType = .done
        sc.searchBar.tintColor = UIColor.black
        sc.searchResultsUpdater = self
        sc.hidesNavigationBarDuringPresentation = false
        sc.dimsBackgroundDuringPresentation = false
        return sc
    } ()

enter image description here

0 个答案:

没有答案