我想知道是否可以在同一导航栏中添加btn.clicked.connect(lambda : btn.setStyleSheet("font: 15px"))
和UISegmentedControl
吗?
我尝试将UISearchBar
的值减到最小,但没有效果:
UISearchBar
我知道像Apple Music这样的应用可以做到这一点:
答案 0 :(得分:4)
尝试一下
let searchBar = UISearchBar()
searchBar.placeholder = "Biblioteket ditt"
searchBar.showsScopeBar = true
searchBar.barTintColor = UIColor(white: 0.9, alpha: 0.1)
searchBar.scopeButtonTitles = ["Apple Music", "Biblioteket ditt"]
// To change UISegmentedControl color only when appeared in UISearchBar
UISegmentedControl.appearance(whenContainedInInstancesOf: [UISearchBar.self]).tintColor = .red
self.navigationItem.titleView = searchBar
这是上面代码的屏幕截图: