【发布时间】:2016-08-26 12:12:04
【问题描述】:
我有一个UITableView,我以编程方式将UISearchController 添加到其中作为标题。由于我以编程方式添加它,因此无法从情节提要中更改字体。我需要更改 UISearchBar 字体以匹配应用程序其余部分的字体。我需要更改UISearchBar 或整个tableViewHeader 的字体
我看到在 Objective-c 中有一个类似的问题,但是我正在 Swift 中开发我的应用程序,我尝试将另一个问题的答案转换为以下代码,但是它仍然无法工作:
let lightFont = UIFont(name: "GothamRounded-Light", size: 15)
for subview in searchController.searchBar.subviews {
if subview is UITextField{
(subview as! UITextField).font = lightFont
}
}
【问题讨论】:
标签: ios swift uitableview uiview uisearchbar