【发布时间】:2021-04-10 18:06:14
【问题描述】:
我试图弄清楚如何以编程方式将搜索栏和范围作为标题添加到我的 UIViewController 我希望它位于安全区域的顶部。问题是我不知道将其添加到 UIViewController 和栏按钮项标题下方安全区域顶部的代码。
func customizeSearch() {
let searchBar = UISearchBar(frame: CGRect(x:0, y:0, width: (UIScreen.main.bounds.width), height: 70))
searchBar.backgroundColor = UIColor.black
searchBar.delegate = self
searchBar.scopeButtonTitles = ["All", "Forwards", "Defensemen", "Goalies"]
/*self.tableView.tableHeaderView = searchBar if I had a tableview, I have a vc instead.*/
}
【问题讨论】:
标签: swift xcode uiviewcontroller