ko1o / PYSearch

🔍 An elegant search controller which replaces the UISearchController for iOS (iPhone & iPad) .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cancelButton 显示不全

xclidongbo opened this issue · comments

let searchVC: PYSearchViewController = PYSearchViewController(hotSearches: [], searchBarPlaceholder: "输入关键字进行搜索")
        searchVC.cancelButton.setTitleColor(CELL_TITLE_COLOR, for: .normal)
        searchVC.hotSearchStyle = PYHotSearchStyle.default
        searchVC.searchHistoryStyle = PYSearchHistoryStyle.normalTag
        searchVC.searchBarBackgroundColor = UIColor(hex: 0xEDF2F8)
        searchVC.delegate = self
        searchVC.searchBarCornerRadius = 15

已经解决. 需要用约束设置cancelButton的宽度. frame方式设置无效.

searchVC.cancelButton.widthAnchor.constraint(equalToConstant: 32).isActive = true
searchVC.cancelButton.heightAnchor.constraint(equalToConstant: 32).isActive = true

参考链接:https://stackoverflow.com/questions/44442573/navigation-bar-rightbaritem-image-button-bug-ios-11