首页 > 解决方案 > iOs:如何在 UITabBarItem 中获得最小比例因子?

问题描述

我想在我的 UITabBarItem 中有一个自适应文本,如果它变得太大,可以最小化字体大小。

例如:

图像1
图2

这是我的代码:

UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Read-Regular", size: 10)!], for: .normal)
                    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont(name: "Read-Regular", size: 10)!], for: .selected)
                    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.black], for: .normal)
                    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white], for: .selected)

是否有任何与标签等效的选项:

valueLabel.adjustsFontSizeToFitWidth = true
valueLabel.minimumFontSize = 0.5

提前致谢。

标签: iosswiftuilabeluitabbaruitabbaritem

解决方案


推荐阅读