tabBarStyle 设置字体大小
时间: 2023-07-04 07:11:25 浏览: 64
您可以通过以下方式设置 tabBarItem 的字体大小:
```swift
// 在 tabBar 的 delegate 方法中设置
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
// 获取当前选中的 tabBarItem
guard let index = tabBar.items?.firstIndex(of: item) else { return }
// 设置字体大小
let font = UIFont.systemFont(ofSize: 20)
tabBar.items?[index].setTitleTextAttributes([NSAttributedString.Key.font: font], for: .normal)
}
```
其中,`UIFont.systemFont(ofSize: 20)` 可以根据您需要设置的字体大小进行修改。