cancelButton 显示不全
xclidongbo opened this issue · comments
xclidongbo commented
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
xclidongbo commented
已经解决. 需要用约束设置cancelButton的宽度. frame方式设置无效.
fujianjin6471 commented
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